Under The Hood
frontend svelte Svelte 5 (runes mode)

Svelte: no virtual DOM — what actually updates

Last updated
Prerequisites:
Basic Svelte syntax
Understanding of what a virtual DOM is and why React/Vue use it
  • svelte
  • virtual-dom
  • compiler
  • dom-updates
  • performance
  • reactivity

Read at your depth

The practical view

React and Vue build a JavaScript description of the UI (the virtual DOM) on every state change, diff it against the previous description, and then apply the minimal set of real DOM changes. Svelte skips that middle layer: the compiler analyzes each component and generates imperative code that updates the exact DOM nodes affected by a state change. So instead of 'create vnode tree → diff → patch', you get 'assign value → set this text node's data'. You write the same declarative templates, but the update path is compiled, direct, and granular.

The same idea in other frameworks

react equivalent
setStaterender() builds vnode tree
reconcile() diffscommits DOM patches

Legacy vs modern

The same counter: vnode diff vs compiled direct updates

The virtual DOM re-creates and diffs a tree on every update; Svelte's compiler emits direct DOM instructions for exactly the bindings that changed.

before → after
Virtual DOM (React-style)
// render() returns a vnode tree; update path:
// render → createElement → reconcile → commit
Svelte compiled updates
let count = $state(0);
<button onclick={() => count++}>+1</button>

Interview gotchas

Under The Hood — a multi-depth technical interview hub.

Press ⌘ K to search.