Skip to content

Build a Svelte app

Checked against 2994ef5 on 2026-11-10 by Capy (review pass: Subagent 124 and fable). The files it covers are unchanged since.

niso’s examples are Svelte 5 apps, because Svelte compiles to plain DOM calls with no virtual DOM, which suits niso well. Nothing in niso is Svelte-specific: React, Vue or plain JavaScript work the same way, through the DOM.

The shortest path is Getting started, which builds a hello example and runs it headless, on the desktop and on phones. This page is about what to do next.

examples/<name>/main.js mounts the root component on document.body, and examples/build.mjs bundles it with esbuild into examples/dist/<name>.js (the script a host runs) and examples/dist/<name>.html (the same page for a browser, to compare against):

Terminal window
(cd examples && pnpm install --frozen-lockfile && node build.mjs)
hosts/iced/build.sh counter
hosts/apple/build.sh counter
hosts/android/build.sh counter

Add <meta name="niso-platform-style" content="auto"> with <svelte:head>, which gives the page the platform’s base style and the --niso-* tokens to style with; the tokens exist only while the meta does (Platform style). Use <button>, <input type="range">, <input type="checkbox" switch> and radio groups for the platform’s own controls (Native controls). examples/controls shows each.

localStorage and IndexedDB persist per app (Storage), so an app can keep its state across launches as a web app would.

Add a widget, a Live Activity or Now Playing controls from the same component: Add a home screen widget, Add a Live Activity, Media session.