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.

Svelte 5 and React at a glance
TopicSvelte 5React
How it shipsCompiler turns components into JavaScriptLibrary loaded in the browser
Component code runsOnce, when the component is createdAgain on each re-render
Local statelet count = $state(0)const [count, setCount] = useState(0)
Computed value$derived(expression)Plain expression in the render body
Side effects$effect, dependencies tracked for youuseEffect with a dependency array
Propslet { name } = $props()Function parameters
Two-way bindingbind:value, $bindable for propsvalue plus onChange
Click handleronclick={...}onClick={...}
Full-stack frameworkSvelteKitNext.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

<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

  1. Choose one of the four components: counter, list, form or effect.
  2. Read the Svelte file on the left and the React file on the right.
  3. Check the note to see which rule of each framework the example shows.
  4. Copy either version into a new project to try it.

Tips

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.

Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.

More in Guides

We.Inc is an AI-powered website builder you can resell under your own brand. Launch a branded client dashboard, bill on Stripe Connect, and deliver AI-generated websites in minutes. White-label plans start at $99 a month for 25 client sites, with a 7-day free trial and no per-site fees.

Product

Who It's For

Features

Resources

Company

View Sitemap