Code · 1 file
Sample Svelte File
Svelte components compile to plain JavaScript. This sample uses Svelte 5 runes. The Svelte sample is a small program — a customer record, a VIP check and a formatted total — that is the same in every language we offer, so you can compare them side by side.
Svelte · 397 B
Sample Svelte component file
An idiomatic Svelte component example: a customer record type, a VIP check, a total and a formatted loop — the same program in every language we offer.
CC0 · free for any use · Verified by an independent tool · Report a problem
<!-- Sample Svelte 5 component — samplefiles.com -->
<script>
let { customers } = $props();
let vipOnly = $state(false);
let shown = $derived(vipOnly ? customers.filter((c) => c.balance >= 10000) : customers);
</script>
<label><input type="checkbox" bind:checked={vipOnly} /> VIP only</label>
<ul>
{#each shown as c (c.id)}
<li>{c.name}: {c.balance.toFixed(2)}</li>
{/each}
</ul>File details
Download from the command line
curl -L -o Sample.svelte https://files.samplefiles.com/code/svelte/Sample.sveltewget https://files.samplefiles.com/code/svelte/Sample.sveltehttps://files.samplefiles.com/code/svelte/Sample.svelteprintf '%s %s\n' c4ee0056d2dc942d171a47e065b0241d61363e60a9b9a8b89197cb79bc412f3e Sample.svelte | shasum -a 256 -cOr check the download in your browser with the checksum calculator.