Svelte compiles your components at build time into vanilla JavaScript — no runtime framework shipped to the browser. This lesson covers components, reactive assignments, conditionals, loops, and event handling.
React, Vue, and Angular ship a runtime to the browser. That runtime interprets your components and updates the DOM. Svelte is a compiler — it analyzes your components at build time and generates precise DOM update instructions. The result is smaller bundles and faster apps.
npm create svelte@latest my-app
# Choose: Skeleton project, No TypeScript (for now), ESLint
cd my-app
npm install
npm run dev
Hello, {name}!
Count: {count} (doubled: {doubled})
$: label is Svelte's reactive declaration syntax. It re-runs whenever any variable it references changes. It's the most elegant reactivity system of any frontend framework.
{#if show}
Visible
{:else}
Hidden
{/if}
{#each fruits as fruit, i (fruit)}
{i + 1}. {fruit}
{/each}
e.key === 'Enter' && addFruit()} />
{title}
{count} items
$: to create a reactive isNegative declaration that's true when count < 0.isNegative.$: to push to it on every change.{#each}. Limit display to the last 10 entries.count += 1 is all you need to update the DOM.$: value = expression is a reactive declaration — recalculates when dependencies change.export let propName to receive props from a parent.