Coming from
WebFluent for Svelte developers
If you write Svelte, WebFluent will feel close: it is also a compiler, state is a plain assignment, and only what reads a changed value updates. What WebFluent adds is a typed markup: every element, prop, flag, event and slot is checked at build time, and the components come designed.
A value that changes
You write
let n = $state(0)
In WebFluent
state n = 0
Changing it
You write
n += 1
In WebFluent
n = n + 1
A value worked out from others
You write
let total = $derived(sum(items))
In WebFluent
derived total = items.sum()
A side effect
You write
$effect(() => { start(); return stop })
In WebFluent
effect { start() cleanup { stop() } }
A handle on an element
You write
<input bind:this={box}>
In WebFluent
Input(bind: q, ref: box)
A component
You write
a .svelte file
In WebFluent
component Card(_ title: String) { … }
Props
You write
let { title, tone = "calm" } = $props()
In WebFluent
component Card(_ title: String, tone: Tone = .calm)
What the caller puts inside
You write
{@render children()}
In WebFluent
children
A snippet the component draws
You write
{@render row(item)}
In WebFluent
slot row(item: Todo), filled as row(todo) { … }
An event
You write
a callback prop, onchange?.(n)
In WebFluent
event change(value: Number), emit change(n)
Two-way binding
You write
<input bind:value={q}>
In WebFluent
Input(bind: q, label: "Search")
Shared state
You write
a store or a .svelte.js module
In WebFluent
store Cart { … }, read as Cart.items after use Cart
A route
You write
SvelteKit src/routes/users/[id]/+page.svelte
In WebFluent
page User(path: "/users/:id", id: String) { … }
{#if}
You write
{#if open}<Panel />{:else}<p>…</p>{/if}
In WebFluent
if open { Panel } else { Text("…") }
{#each}
You write
{#each items as i (i.id)}<li>{i.name}</li>{/each}
In WebFluent
for i in items by i.id { Text(i.name) }
{#await}
You write
{#await promise}…{:then data}…{:catch e}…{/await}
In WebFluent
match users { .loading { … } .loaded(list) { … } .failed(e) { … } }
A class that follows state
You write
class:done={todo.done}
In WebFluent
class: { "done": todo.done }
Transitions
You write
transition:fade
In WebFluent
.fadeIn, exit: .fadeOut
A test
You write
Vitest with Testing Library: render, fireEvent.click, getByText
In WebFluent
test "…" { click "Save" expect "Saved" }
Things that work differently
The elements are typed too. svelte-check types your props and the expressions in your markup; WebFluent also knows every built-in's flags, events and slots. Button("Save").primray does not build, and neither does a handler for an event the component does not fire (E103).
Typed without a second language. svelte-check reads TypeScript beside the markup; a .wf file is typed by the compiler that builds it. The checker infers what it can and asks you to write the rest: a state whose first value says nothing (state items: [Todo] = []), an action that returns (-> Number), a parameter. There is no any: JSON whose shape is open is Json, matched or decoded (User.decode(raw)) before it is read, and no setting turns the checks off.
Elements come designed. Button, Card, Table, Modal and the rest are built in, with their accessibility work done, and a flag picks a variant (.primary, .lg). Your own look is a theme of design tokens and a style { } on the element.
Pages own their routes. There is no src/routes folder: each page names its path:, and the compiler builds the router from every page, ordered by specificity.
No imports. Every file under src/ is part of one program, so a component declared anywhere is usable everywhere.
Fetching is a value. A resource is read with match, and asks again when a state its address reads changes; an api block describes a service once, so every call is typed, cached and cancellable, and answers with a result rather than throwing.
The build is the site. Pre-rendering, code splitting, image resizing and a Content-Security-Policy come from wf build; there is no server to run.
A component, ported
The same counter, in Svelte and in WebFluent. It starts at a number the caller passes, counts up on a click, shows a badge when the count is even, and tells the caller about each change.
<script>
let { start = 0, onchange } = $props();
let n = $state(start);
let even = $derived(n % 2 === 0);
function inc() { n += 1; onchange?.(n); }
</script>
<div class="row">
<button onclick={inc}>+</button>
<span>{n}</span>
{#if even}<span class="badge">even</span>{/if}
</div>
page Scores(path: "/", title: "Scores", description: "A counter that reports each change.") {
state last = 0
Heading("Scores").h1
Counter(start: 2) { on change(value) { last = value } }
Text("Last change: {last}")
}
component Counter(start: Number = 0) {
event change(value: Number)
state n = start
derived even = n % 2 == 0
Row(gap: .sm, align: .center) {
Button("+") { on click { n = n + 1 emit change(n) } }
Text("{n}")
if even { Badge("even").info }
}
}
- The same reactivity, spelled
stateandderived. - The event is declared, so a caller's misspelled handler is a build error rather than a prop nobody reads.
- No
class.Badgecomes designed, and.infois checked.