Web Framework Deep Dive

Svelte

A radical idea: do the work at compile time. Svelte compiles your components into tiny vanilla-JS that touches the DOM directly — no virtual DOM, smallest bundles, fastest runtime.

JavaScript / TypeScriptCompilerNo Virtual DOMTiny BundlesLoved DX
← Back to Client Side
Quick Facts

At a Glance

Created
2016 · Rich Harris
Style
Compiler — no runtime VDOM
Latest
Svelte 5 (Runes)
Steward
Vercel + community
Notable users
Apple, Spotify, IKEA, NYT (the original Svelte demo)

Basic Concepts

  • Compile, don't ship: Svelte takes your .svelte file and emits surgical DOM update code — no framework runtime to download.
  • Reactivity by assignment (Svelte 3-4) or Runes (Svelte 5: $state, $derived, $effect).
  • Single-file components with <script>, markup, and scoped <style>.
  • Built-in animations & transitions as a first-class concept.
  • Stores for cross-component reactive state.
Syntax

Taste of Svelte 5 (Runes)

<script>
  let products = $state([]);
  let loading  = $state(true);

  $effect(async () => {
    const res = await fetch('/api/products');
    products = await res.json();
    loading  = false;
  });
</script>

{#if loading}
  <p>Loading…</p>
{:else}
  <ul>
    {#each products as p (p.id)}
      <li>{p.name} — \${p.price}</li>
    {/each}
  </ul>
{/if}

<style>
  ul { padding-left: 1.5rem; }
</style>
Mechanics

Key Features

The Compiler Approach

React/Vue ship a runtime that interprets your components in the browser. Svelte ships your component, compiled to direct DOM manipulation. Result: smaller bundles, faster updates, lower memory — all without giving up an ergonomic API.

Runes (Svelte 5)
  • $state — reactive variable.
  • $derived — computed value (think useMemo).
  • $effect — side effect, like Vue's watchEffect.
  • $props — declare component props.

Runes make reactivity explicit and scale better than the implicit "let" reactivity of Svelte 3/4.

Stores

Cross-component state via writable, readable, derived stores — subscribe with $store auto-syntax. Svelte 5 also lets you put $state into plain JS modules for global reactive state.

Animations & Transitions

First-class transition:fade, animate:flip, in:slide, out:scale directives. The animations API is one of Svelte's most distinctive features.

Ecosystem
  • Meta-framework: SvelteKit — routing, SSR, SSG, server endpoints.
  • UI kits: Skeleton, shadcn-svelte, Flowbite Svelte, Bits UI.
  • State: built-in stores; Runes; Svelte/store helpers.
  • Test: Vitest + Playwright.
Trade-offs

Strengths & Weaknesses

Strengths
  • Smallest bundles & fastest runtime of the major frameworks.
  • Most-loved framework on developer surveys.
  • Built-in transitions, scoped styles, stores — less to assemble.
  • Closer to plain HTML/CSS/JS than React or Angular.
Weaknesses
  • Smallest hiring pool of the four major frameworks.
  • Smaller component-library ecosystem.
  • Svelte 5 is a notable migration from 3/4.
  • Some build tooling specific to .svelte files.
Where It Shines

Sweet Spots

Performance-Sensitive Sites

News, marketing, e-commerce — every kilobyte counts.

Embedded Widgets

Tiny bundles make Svelte great for embeds & micro-frontends.

Animated, Interactive UIs

Built-in animations save dozens of dependencies.

Solo Devs & Small Teams

Less code, fewer concepts, faster iteration.

Continue

Other Web Frameworks