Svelte 5 has been out for two years, and if you write React all day, you have probably been ignoring it for most of that time. That was defensible in 2024. It is harder to defend now: Svelte 5 is at version 5.59.1, SvelteKit 3 shipped in October 2026, the scaffolding CLI hit 1.0, and the framework just celebrated its tenth birthday at Svelte Summit in Ljubljana. This guide translates Svelte 5 into React terms, so you can read real Svelte code by the end of it — and decide whether your next side project should be built with it.
Every version number, command, and API below was checked against the official Svelte documentation on 21 November 2026.
Why Svelte 5 deserves your attention in 2026
React and Svelte solve the same problem — turning state into a user interface — but they disagree about where the work happens. React ships a runtime library that re-renders components and reconciles a virtual DOM in the browser. Svelte is a compiler: it analyses your component at build time and emits small, surgical JavaScript that updates exactly the DOM nodes that changed. There is no virtual DOM to diff and no runtime framework to download. Svelte 5 pairs that compiler with a new reactivity system, runes, which feels closer to React’s mental model than anything Svelte shipped before.
Three facts make now the right moment to learn it:
- Svelte 4 is end of life. Version 4 stopped receiving security updates on 19 October 2024, the day Svelte 5 shipped. Svelte 5 is the only supported line, currently at 5.59.1 (released 20 November 2026).
- The ecosystem just had its biggest refresh in two years. SvelteKit 3 shipped in October 2026 alongside
sv1.0, the official CLI. The framework turned ten at Svelte Summit on 19–20 November 2026. - It is no longer a toy. The
sveltepackage recorded roughly 9.4 million npm downloads in the week of 3–9 November 2026. That is still a fraction of React’s numbers, but it is a healthy, growing ecosystem with real production users.
Set up your first Svelte 5 project
You scaffold a Svelte 5 app with the sv CLI, which reached 1.0 in October 2026. New projects use SvelteKit 3 by default:
npx sv create my-svelte-app
cd my-svelte-app
npm install
npm run dev
The CLI asks a short series of questions — which template, whether to add TypeScript, a linter, and add-ons such as Tailwind or Drizzle — then writes a working project. The dev server starts on http://localhost:5173 by default, with hot module replacement that is noticeably faster than a typical React dev server because the compiler does most of the work up front.
Your first component: the .svelte file
A Svelte component is a single .svelte file with three parts: a <script> block for logic, markup for the template, and a <style> block for CSS. Styles are scoped to the component by default — no CSS Modules, no naming convention, no runtime cost:
<script>
let name = $state('world');
</script>
<h1>Hello {name}!</h1>
<button onclick={() => (name = 'Svelte')}>Change name</button>
<style>
h1 {
color: #bb1919;
}
</style>
Two things will feel strange if you come from React. First, there is no JSX: the template is HTML with {expressions} in curly braces. Second, there are no imports for the reactive primitives — $state and friends are compiler directives, not functions you import. TypeScript works natively in Svelte 5, with no preprocessor to configure: add lang="ts" to the script tag and write types directly.
$state: Svelte 5’s answer to useState
Here is the same counter in React and in Svelte 5. The difference is the point of the whole framework:
// React
import { useState } from 'react';
export default function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(count + 1)}>clicks: {count}</button>;
}
<!-- Svelte 5 -->
<script>
let count = $state(0);
</script>
<button onclick={() => count++}>clicks: {count}</button>
$state(0) declares a reactive variable. You read it like a normal variable and write to it like a normal variable — count++ just works. There is no setter function, no .value wrapper, and no re-render of the whole component: the compiler tracks exactly which DOM nodes read count and updates only those.
Objects and arrays are deeply reactive. Svelte wraps them in a proxy, so mutating a nested property triggers an update:
<script>
let user = $state({ name: 'Ada', todos: [] });
</script>
<button onclick={() => user.todos.push('Learn runes')}>Add todo</button>
<!-- No setState, no spread, no new array — the push alone updates the UI -->
In React that push would be a bug: you must create a new array so the reference changes. In Svelte it is the idiomatic way to write it. Two escape hatches cover the cases where deep reactivity is wrong:
$state.raw()creates shallow state — only reassigning the variable itself triggers an update. Use it for large objects you replace wholesale, or for values such as class instances where proxying would break things.$state.snapshot()returns a plain, non-reactive copy of a state value. Use it before passing state to a library that mutates its input, or before sending it tostructuredCloneorJSON.stringifyin contexts where proxies misbehave.
$derived: Svelte 5’s answer to useMemo
A derived value is computed from other state. It recalculates lazily — only when something actually reads it — and it is cached between reads, which is exactly the job useMemo does in React:
<script>
let price = $state(25);
let quantity = $state(4);
let total = $derived(price * quantity);
</script>
<p>Total: ${total}</p>
For derivations that need more than one expression, use $derived.by() with a function body:
<script>
let items = $state([
{ name: 'Keyboard', price: 120, inStock: true },
{ name: 'Mouse', price: 45, inStock: false },
{ name: 'Monitor', price: 300, inStock: true }
]);
let inStockTotal = $derived.by(() => {
return items
.filter((item) => item.inStock)
.reduce((sum, item) => sum + item.price, 0);
});
</script>
The rule the Svelte docs repeat, and the one that will save you the most debugging time, is this: if you are computing a value, use $derived. If you are doing something — touching the DOM, fetching, logging — use $effect. Roughly 90% of the time, you want $derived.
$effect: Svelte 5’s answer to useEffect
Effects run side effects when their dependencies change. Unlike React’s useEffect, you never list dependencies: the compiler watches which reactive values your effect reads synchronously and re-runs it when any of them change:
<script>
let count = $state(0);
$effect(() => {
localStorage.setItem('count', String(count));
console.log('count is now', count);
});
</script>
Effects run after the component mounts and after the DOM updates — the equivalent of useEffect, not useLayoutEffect. If you need to run code before the DOM updates, $effect.pre() is the equivalent of useLayoutEffect. Returning a function from an effect registers it as cleanup, exactly like React:
<script>
let query = $state('');
$effect(() => {
const controller = new AbortController();
fetch(`/api/search?q=${query}`, { signal: controller.signal });
return () => controller.abort();
});
</script>
One timing difference catches React developers out: in Svelte 4, $: statements ran immediately before rendering. $effect runs after rendering, so if you find yourself writing an effect that only assigns to another $state variable, stop — that is a $derived, and writing it as an effect creates an extra render and a class of bugs the docs explicitly warn about.
$props and $bindable: how props work in Svelte 5
React components receive a single props object. Svelte 5 components receive props through one $props() call, destructured like a normal object. Defaults, renaming, and rest props are plain JavaScript destructuring — there is no special syntax to learn:
<script lang="ts">
let {
title,
price,
inStock = true,
class: klass,
...rest
}: {
title: string;
price: number;
inStock?: boolean;
class?: string;
} = $props();
</script>
<article class={klass} {...rest}>
<h2>{title}</h2>
<p>${price} — {inStock ? 'In stock' : 'Sold out'}</p>
</article>
Two-way binding, the thing React deliberately does not do, is explicit in Svelte. Mark a prop with $bindable() and the parent can bind to it with bind::
<!-- Child: Counter.svelte -->
<script>
let { count = $bindable(0) } = $props();
</script>
<button onclick={() => count++}>{count}</button>
<!-- Parent -->
<script>
import Counter from './Counter.svelte';
let total = $state(0);
</script>
<Counter bind:count={total} />
<p>Parent sees: {total}</p>
Use $bindable sparingly — for form inputs and genuinely shared values, not as a default. Most props should flow one way, exactly as in React.
Events are just props now
This is the change that breaks the most old Svelte tutorials. In Svelte 4, you attached handlers with the on: directive and emitted component events with createEventDispatcher. In Svelte 5, event handlers are ordinary properties — drop the colon — and components communicate upward through callback props:
<!-- Svelte 5 -->
<button onclick={() => count++}>clicks: {count}</button>
<!-- Passing a callback prop to a child component -->
<Pump oninflate={(power) => size += power} />
createEventDispatcher is deprecated. Event modifiers such as |preventDefault and |once are gone too — call event.preventDefault() inside the handler instead. The one modifier that survives in a different form is capture, written as onclickcapture.
Snippets replace slots
Slots are deprecated in Svelte 5. Their replacement, snippets, is a block of markup you define once and render wherever you want with {@render ...}. The most common case is children, which is how you pass content into a component — the equivalent of React’s children prop:
<!-- Card.svelte -->
<script>
let { children, header } = $props();
</script>
<div class="card">
{#if header}
<header>{@render header()}</header>
{/if}
{@render children()}
</div>
<!-- Parent -->
<Card>
{#snippet header()}
<h2>Snippets, not slots</h2>
{/snippet}
<p>This paragraph is the children snippet.</p>
</Card>
Snippets are more powerful than slots because they can take arguments, which makes them suitable for render-prop patterns that in React you would write as a function-as-child.
Shared state without stores: .svelte.js files
One of the best parts of runes is that they work outside components. Rename a module to .svelte.js or .svelte.ts and you can use $state inside it, then import that state from any component. This replaces the store pattern entirely for most apps:
// cart.svelte.ts
export const cart = $state({
items: [],
get total() {
return cart.items.reduce((sum, item) => sum + item.price, 0);
}
});
export function addItem(item) {
cart.items.push(item);
}
<!-- Any component -->
<script>
import { cart, addItem } from './cart.svelte.js';
</script>
<p>{cart.items.length} items — ${cart.total}</p>
<button onclick={() => addItem({ name: 'Keyboard', price: 120 })}>
Add keyboard
</button>
Every component that reads cart updates when it changes, with no provider, no context, and no subscription boilerplate. For a React developer, the closest analogy is a tiny Zustand store — except there is no library, and the state lives in a plain module file.
The runes cheat sheet
| Rune | What it does | React equivalent |
|---|---|---|
$state() |
Declares reactive state, deeply reactive by default | useState |
$state.raw() |
Shallow state — only reassignment triggers updates | Storing a ref-like value you replace wholesale |
$state.snapshot() |
Plain, non-reactive copy of a state value | Reading a ref’s current value to pass on |
$derived() |
Value computed from other state, cached and lazy | useMemo |
$derived.by() |
Multi-statement derivation | useMemo with a function body |
$effect() |
Side effect, runs after DOM updates | useEffect |
$effect.pre() |
Side effect, runs before DOM updates | useLayoutEffect |
$effect.tracking() |
Returns true inside an effect-tracking context | — |
$props() |
Declares component props via destructuring | The props object |
$bindable() |
Marks a prop as two-way bindable | Controlled input with value + onChange |
$inspect() |
Logs a value whenever its dependencies change | console.log inside an effect |
Runes mode switches on the moment any rune appears in a file — there is no config flag. If you are migrating an existing Svelte 4 codebase, you do not have to convert everything at once: Svelte 5 still supports the old syntax, and you can mix old and new components while the migration script (npx sv migrate) converts the mechanical parts.
SvelteKit 3: what changed in October 2026
SvelteKit is the official application framework for Svelte — routing, server-side rendering, data loading, and deployment adapters, roughly the role Next.js plays for React. Version 3 shipped in October 2026, and the official announcement describes it honestly: the same framework, with a little more polish, a little more type safety, and a little less junk.
Higher minimum versions
SvelteKit 3 raises the floor on everything underneath it. The official migration guide lists these minimums:
| Dependency | Minimum version |
|---|---|
| Node.js | v22.17 |
| TypeScript | v6 |
| Svelte | v5.57.1 |
| Vite | v8.0.12 (the first Vite 8 release bundling stable Rolldown v1) |
@sveltejs/vite-plugin-svelte |
v7 |
The TypeScript 6 requirement is the one most likely to catch you: teams that pinned TypeScript 5 for plugin compatibility will need to deal with that first. Vite 8 replaces the esbuild-plus-Rollup pair with Rolldown, a Rust bundler.
Configuration moves into vite.config.ts
svelte.config.js is gone entirely. All configuration now lives in the sveltekit Vite plugin inside vite.config.ts, with options that used to sit under config.kit.* promoted to top-level plugin options:
import { defineConfig } from 'vite';
import { sveltekit } from '@sveltejs/kit/vite';
import adapter from '@sveltejs/adapter-auto';
export default defineConfig({
plugins: [
sveltekit({
compilerOptions: { experimental: { async: true } },
adapter: adapter()
})
]
});
Several options were removed outright and should just be deleted: preloadStrategy (modulepreload is now always used), prerender.origin (replaced by a top-level paths.origin), and csrf.checkOrigin (replaced by csrf.trustedOrigins — CSRF protection is always on in SvelteKit 3).
$lib becomes #lib
SvelteKit no longer generates the $lib alias. It is replaced by a #lib alias that you declare yourself in the imports field of package.json, using Node’s built-in subpath imports, which Vite and TypeScript resolve natively:
{
"imports": {
"#lib": "./src/lib/index.js",
"#lib/*": "./src/lib/*"
}
}
Then replace $lib with #lib across the codebase — and note the sharp edge: you must now include the module extension, so import { foo } from '$lib/foo' becomes import { foo } from '#lib/foo.js'. The migration script handles most of this, but check any dynamic imports by hand.
$app/stores is removed — use $app/state
The old $app/stores module, which exported the $page, $navigating, and $updated stores, is gone. Its replacement, $app/state, exposes the same values as fine-grained Svelte 5 state, and you drop the $ prefix when reading them:
<script>
import { page } from '$app/state';
</script>
<p>current pathname: {page.url.pathname}</p>
Two related changes matter in practice. First, page.url is now typed as a ReadonlyURL, so mutating it is a type error; copy it into a new URL first. Second, $app/environment is renamed to $app/env and can now be imported inside service workers, which previously needed the now-removed $service-worker module. A new $app/manifest module exposes build metadata (assets, prerendered, routes) for offline caching and similar jobs.
Navigation and error handling
error()now requires a message:error(404, 'Post not found')instead oferror(404).invalidateAllis deprecated in favour ofrefreshAll, which does not resetpage.stateto an empty object.- Shallow routing moves from
pushState/replaceStateintogoto:goto('/foo', { shallow: true, state }), with apersistState: trueoption to reapply state after a reload. gotooptions were consolidated:keepFocusandnoScrollbecome a singlereset: false, andreplaceStatebecomesreplace.- Version polling now defaults to one hour, so
updated.currentbecomestrueautomatically when a new deployment lands — previously nothing polled by default. - The
json()andtext()response helpers are deprecated in favour ofResponse.json()andnew Response(text).
One thing SvelteKit 3 does not ship: remote functions, the type-safe client-server communication layer the team has been previewing. The announcement is explicit that they are not ready yet and remain the top priority, gated behind the experimental Async Svelte flag for now. Do not build a SvelteKit 3 app around them today.
Should you switch from React?
Honest answer: probably not for your main production app tomorrow, and definitely yes for your next side project. The trade-offs are real on both sides:
| Svelte 5 wins | React wins | |
|---|---|---|
| Bundle size | No runtime library; the compiler emits only what you use | React 19 is leaner than it was, but still ships a runtime |
| Learning curve | Less boilerplate; state is plain assignment | You already know it; your team already knows it |
| Ecosystem | SvelteKit 3 covers the framework layer well | Massively larger component, job, and hiring market |
| Performance | Fine-grained updates with no virtual DOM diffing | React Compiler closes much of the gap in 19.x |
| Best fit | Content sites, dashboards, internal tools, interactive widgets | Large teams, huge codebases, React Native sharing |
The case for learning Svelte 5 even if you never ship it is stronger than the case for switching: runes are the clearest expression of the signals idea spreading across every framework, and seeing how a compiler-first framework solves state, effects, and composition will make you a better React developer.
7 mistakes React developers make in Svelte 5
1. Reaching for $effect when you want $derived
The single most common mistake, and the docs warn about it directly. If your effect only computes a value and assigns it to state, it should be a $derived.
2. Treating $state like useState
There is no setter and no stale-closure problem, so patterns like setCount(c => c + 1) have no equivalent — and no need for one. Just write count++. The flip side: do not destructure state and expect the destructured copy to stay reactive.
3. Mutating $state.raw() and expecting an update
$state.raw is shallow on purpose. Pushing to an array held in $state.raw does nothing visible — you must reassign the whole value. If you are unsure, use plain $state and reach for .raw only when profiling shows deep reactivity is the bottleneck.
4. Copying Svelte 4 syntax from old tutorials
Any tutorial that uses on:click, export let, $:, slots, or createEventDispatcher is teaching Svelte 4. The old syntax still compiles in Svelte 5, which makes it worse: your code works, but you are learning the framework twice.
5. Mutating page.url in SvelteKit 3
page.url is a ReadonlyURL in SvelteKit 3. Code that called page.url.searchParams.set() in SvelteKit 2 is now a type error. Copy first: const url = new URL(page.url.href).
6. Importing from $lib in a SvelteKit 3 app
The $lib alias is gone. New code imports from #lib with a file extension (#lib/foo.js), and the alias must be declared in package.json. This is the migration change most likely to produce a wall of red import errors on day one.
7. Skipping the SvelteKit 3 minimum versions
SvelteKit 3 needs Node 22.17+, TypeScript 6, Svelte 5.57.1+, and Vite 8.0.12. Upgrading the framework without upgrading the toolchain produces confusing errors that look like framework bugs. Upgrade to the latest SvelteKit 2.x first, read the deprecation warnings, then run npx sv migrate sveltekit-3.
Put it together: a working todo list
Everything above fits into one component. This is a complete, working Svelte 5 todo list — state, derivation, effects, props, events, and a snippet — in about sixty lines:
<script>
let todos = $state([
{ id: 1, text: 'Learn $state', done: true },
{ id: 2, text: 'Learn $derived', done: false }
]);
let draft = $state('');
let filter = $state('all');
let visible = $derived(
todos.filter((t) =>
filter === 'all' ? true : filter === 'done' ? t.done : !t.done
)
);
let remaining = $derived(todos.filter((t) => !t.done).length);
$effect(() => {
localStorage.setItem('todos', JSON.stringify(todos));
});
function addTodo() {
if (!draft.trim()) return;
todos.push({ id: Date.now(), text: draft.trim(), done: false });
draft = '';
}
</script>
<h1>Todos ({remaining} left)</h1>
<input
bind:value={draft}
onkeydown={(e) => e.key === 'Enter' && addTodo()}
placeholder="What needs doing?"
/>
<button onclick={addTodo}>Add</button>
<div>
<button onclick={() => (filter = 'all')}>All</button>
<button onclick={() => (filter = 'active')}>Active</button>
<button onclick={() => (filter = 'done')}>Done</button>
</div>
<ul>
{#each visible as todo (todo.id)}
<li>
<input type="checkbox" bind:checked={todo.done} />
{todo.text}
</li>
{/each}
</ul>
Notice what is missing compared with the React version of the same app: no useState imports, no setter functions, no spread copies when toggling a checkbox, no dependency arrays, and no memoisation wrappers. That is the whole pitch for Svelte 5 in one file.
Further Reading & References
- Svelte 5 migration guide — the official guide to runes, events, snippets, and every breaking change from Svelte 4.
- SvelteKit 3 is here — the official announcement, including the
sv migratecommand and the remote-functions status. - Migrating to SvelteKit v3 — the official migration guide: minimum versions, the config move,
#lib,$app/state, and every deprecation. - What’s new in Svelte: October 2026 — the official monthly roundup covering the SvelteKit 3 release,
sv1.0, and Svelte Summit. - Svelte 5 runes — the complete guide — a deep dive into every rune, including the variants (
$state.eager,$effect.tracking,$props.id) this guide only mentions. - Svelte 5 is here — This Dot Labs’ launch overview of runes, snippets, and the compiler changes.
- Getting started with Svelte 5: a guide for React developers — a React-developer-focused walkthrough of the same translation this guide covers.
- Svelte end-of-life dates — release and support dates, confirming Svelte 5.59.1 as the current release (20 November 2026) and Svelte 4’s end of life.
- React 19.3: View Transitions, Fragment Refs, and What to Upgrade First (2026) — the React side of the comparison, and the version this guide benchmarks against.
- Astro 7: The Complete Guide to the Astro Framework (2026) — another compiler-first framework worth comparing with SvelteKit 3.
- Next.js Middleware in 2026: The Complete Guide (It’s Called Proxy Now) — the Next.js 16 counterpart to SvelteKit 3’s routing and middleware story.
All facts verified 21 November 2026 against the official Svelte documentation, the SvelteKit 3 announcement and migration guide, and npm release data.



