Svelte vs React: One Component, Two Ways
Svelte is a compiler: it turns .svelte files into plain JavaScript, and state declared with the $state rune updates the page directly. React is a library where a component function runs again on every state change and returns new JSX. Svelte usually means less code per component; React brings the larger ecosystem and hiring pool.
| Topic | Svelte 5 | React |
|---|---|---|
| How it ships | Compiler turns components into JavaScript | Library loaded in the browser |
| Component code runs | Once, when the component is created | Again on each re-render |
| Local state | let count = $state(0) | const [count, setCount] = useState(0) |
| Computed value | $derived(expression) | Plain expression in the render body |
| Side effects | $effect, dependencies tracked for you | useEffect with a dependency array |
| Props | let { name } = $props() | Function parameters |
| Two-way binding | bind:value, $bindable for props | value plus onChange |
| Click handler | onclick={...} | onClick={...} |
| Full-stack framework | SvelteKit | Next.js and others |
Updated
Pick a component below and read the Svelte 5 version next to the React version. Both do exactly the same thing, so the difference you see is only the framework. Every snippet is complete and runs as written in a fresh project.
The same component in Svelte and React
- Counter
- List
- Form
- Effect
<script>
let count = $state(0);
</script>
<button onclick={() => count++}>
Clicked {count} times
</button>import { useState } from "react";
export default function Counter() {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount(count + 1)}>
Clicked {count} times
</button>
);
}Svelte lets you write count++ because $state makes the variable reactive. React needs the setter, and the new value shows up on the next render.
Start a project in each
Scaffold commands
The first command starts a SvelteKit app with the official sv tool; the second starts a Next.js app, the React framework with the most documentation.
# Svelte (SvelteKit)
npx sv create my-svelte-app
# React (Next.js)
npx create-next-app@latest my-react-app
Runes versus hooks
Svelte 5 replaced its older implicit reactivity with runes: $state, $derived, $effect, $props and $bindable. They look like function calls but are compiler keywords, so the compiler can wire each value to the parts of the page that read it.
React hooks are ordinary functions that must be called at the top level of a component, in the same order every render. useState gives you a snapshot of the value and a setter, and the new value only appears on the next render.
Effects and dependencies
A Svelte $effect tracks whatever state it reads synchronously and re-runs when that state changes. Values read after an await are not tracked. React asks you to list every reactive value in the dependency array of useEffect, and its linter warns when one is missing.
Both run only in the browser, never during server rendering, and both accept a returned cleanup function that runs before the next run and on unmount.
When each one fits
Pick Svelte for content sites, widgets and small teams who want less code and are happy with a smaller library catalogue. Pick React when you need a specific React library, a large team, or a framework such as Next.js that your hosting is built around.
How it works
- Choose one of the four components: counter, list, form or effect.
- Read the Svelte file on the left and the React file on the right.
- Check the note to see which rule of each framework the example shows.
- Copy either version into a new project to try it.
Tips
- In Svelte, mutate arrays and objects held in $state directly. In React, always pass a new array or object to the setter.
- Do not reach for $effect to keep two values in sync. A $derived value is the Svelte answer, just as React suggests computing it during render.
- If your team already knows React, the hiring and library argument usually outweighs the smaller Svelte components.
- Try a small internal page in Svelte before a full switch. Interop between the two in one app is possible but rarely worth it.
Frequently asked questions
Is Svelte faster than React?
We do not quote speed numbers here because results depend on the app and the test. The structural difference is real: Svelte compiles away the framework layer and updates only what changed, while React re-runs components and compares the result.
Does Svelte 5 still use let for reactive state?
Not on its own. In Svelte 4 a top-level let was reactive by default. Svelte 5 makes it explicit: a variable becomes reactive when you create it with $state.
What is the Svelte version of Next.js?
SvelteKit. The Svelte docs call it the companion application framework, and it adds routing, server rendering and data loading on top of Svelte components.
Can I use React libraries in Svelte?
Not directly. React components need React to render. Plain JavaScript libraries without a UI layer, such as date or validation helpers, work in both.
Which should a beginner learn first?
Svelte templates are closer to plain HTML, so the first steps are gentler. React has far more tutorials and job listings. If employment is the goal, start with React.
Related: Svelte 5 runes explained, React hooks cheat sheet, Next.js vs React, Astro vs Next.js, React with TypeScript.
Build your site free or see all free tools. On We.Inc you can build your site free, with no card and no trial needed to start. AI building is on paid plans from $19 a month.
More in Guides
- SVG Animation: 20 Live Examples With Code
- Tailwind Animations: Built-in Classes and Custom Keyframes
- Tailwind CSS v4 Cheat Sheet (Searchable) | How-to Guide
- Tailwind CSS Colors: The Full Default Palette
- Tailwind vs Bootstrap: One Section, Built Twice
- Team Page Examples
- Terms of Service vs Privacy Policy
- Is a White-Label Website Builder Good for Client SEO? A 12-Point Test to Run Before You Commit | How-to Guide
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App