A Svelte component that never touches an HTML element, yet still runs $state, {#each} and onclick as usual: that is what Svelte custom renderers make possible. The Svelte team shipped the API behind an experimental flag in Svelte 5.59.0 on November 20, 2026. Instead of writing to the browser, a component can render into a 3D scene, a terminal UI, a PDF or a native app. We tried it with Svelte 5.59.2 on Node.js 24 to see what already works, where the compiler draws the line and why production code should wait a little longer.
What Svelte custom renderers actually replace
Until now, Svelte was hard-wired to the DOM. The compiler turns a component into JavaScript that creates elements, sets attributes and swaps text directly. The new API puts a layer in between. The Svelte docs on custom renderers describe it like this: “The renderer is a small object that tells Svelte how to create, arrange and update the nodes of the target environment. Svelte takes care of everything else.” Reactivity, props, control flow and lifecycle stay with Svelte. Only the last step, turning nodes into something visible, moves to your code.
One detail matters for understanding the model: elements such as <mesh> or <box> mean nothing to Svelte. The compiler hands their names and attributes to the renderer, and the renderer decides what they become. So the renderer alone defines which elements exist. The docs list WebGL scenes, native mobile UIs, terminals and PDF documents as targets, and the December release roundup puts it in one line: “The custom renderer API is now available behind an experimental flag. You can use it to render Svelte components to native apps, terminal UIs, PDFs and more.” What the Svelte team has not shipped is a ready-made renderer package. The examples in the docs, three-renderer and terminal-renderer, are explicitly made up.
Turning it on: one flag, one line per component
This is a compiler feature of Svelte 5. You enable it with compilerOptions.experimental.customRenderer, usually in vite.config.js or svelte.config.js, and the option takes three shapes:
// vite.config.js
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
export default defineConfig({
plugins: [
svelte({
compilerOptions: {
experimental: {
// true: each component opts in via <svelte:options>
// 'package-name': default renderer for every component
// ({ filename }) => ...: pick a renderer per file
customRenderer: true
}
}
})
]
});
With true, every component keeps rendering to the DOM until it points at a renderer module with <svelte:options customRenderer="..." />. The path resolves like any other import, so a package name, an alias or a relative path such as ./renderer.js all work. Pass a module path instead of true and it becomes the default, while individual components can opt out with customRenderer={null}. The docs flag one trap: a globally configured default can’t be relative, because every component imports it and the path would be resolved against each file rather than your config. Use a package name, a subpath import like #lib/renderer.js or an absolute path. The third shape is a function that receives each component’s filename and returns a renderer or null, for example for everything under src/scene/.
Without the flag the compiler refuses outright. In our test it reported that customRenderer can’t be set in <svelte:options> unless the compiler option is enabled.
How to create a custom renderer
A renderer module’s default export is an object built with createRenderer from svelte/renderer. According to the docs, createRenderer returns its argument unchanged and exists only for type safety. Svelte works with four kinds of nodes: fragments, elements, text nodes and comments. Comments act as invisible markers, for instance to remember where an {#if} block goes, so they never need to be displayed.
The methods fall into four groups. Creating nodes: createFragment, createElement, createText and createComment, plus getNodeType, getText and setText. The tree: insert(parent, node, anchor), remove, getParent, getFirstChild, getLastChild and getNextSibling. Attributes: setAttribute, removeAttribute, getAttribute and hasAttribute. Events: addEventListener and removeEventListener. That is 19 methods, plus two optional ones for mixing renderers.
Two behaviours differ from what you might expect in the browser. First, setAttribute receives the value exactly as written in the component, so numbers, arrays, objects and functions arrive as they are rather than as strings. Only class and style are always strings, because Svelte merges them with class: and style: directives and the scoping class first. Second, Svelte doesn’t call removeEventListener when an element is removed; element and listeners are meant to be discarded together. The docs include a complete example renderer that renders to plain JavaScript objects, and that is exactly what we used for our test.
Hands-on: running Svelte components in Node.js
We installed svelte@5.59.2, compiled a small counter with svelte/compiler and experimental.customRenderer: true, and ran it on Node.js 24.22.1. The component uses props, $state, $derived, a keyed {#each} block and a click handler:
<!-- Counter.svelte -->
<svelte:options customRenderer="./renderer.js" />
<script>
let { label = 'Clicks' } = $props();
let count = $state(0);
let items = $derived(Array.from({ length: count }, (_, i) => i + 1));
</script>
<panel title={label}>
<text>{label}: {count}</text>
{#each items as n (n)}
<item index={n}>Entry {n}</item>
{/each}
<button onclick={() => count++}>+1</button>
</panel>
Startup follows the docs: the renderer creates a fragment as the target, and mount gets the renderer as an extra option. With no browser around, we fire the click ourselves by calling the handlers the renderer stored in addEventListener:
// main.mjs
import { mount, flushSync, unmount } from 'svelte';
import renderer from './renderer.js';
import Counter from './Counter.js'; // compiled beforehand with svelte/compiler
const root = renderer.createFragment();
const app = mount(Counter, { target: root, renderer });
const button = root.children[0].children.find((n) => n.name === 'button');
// "click" twice: the renderer calls the stored handlers
for (let i = 0; i < 2; i++) {
for (const handler of button.listeners.click) handler();
}
flushSync();
console.log(print(root)); // print(): small tree printer, omitted here
unmount(app);
Here is the result after two clicks, once with and once without the required resolve condition:
$ node --conditions=svelte-custom-renderer main.mjs
<panel title="Clicks">
<text>
"Clicks: 2"
<item index=1>
"Entry 1"
<item index=2>
"Entry 2"
<button>
"+1"
$ node main.mjs
Error: https://svelte.dev/e/custom_renderer_unavailable_on_server
With --conditions=svelte-custom-renderer everything behaved: the text updated, the {#each} block created two new objects, and after unmount the fragment was empty again. At the top level, next to the panel, sat a single comment node, the invisible marker the docs describe. Without the condition Node.js fails as soon as it loads the renderer. The docs explain why, and Svelte’s package.json confirms it: outside the browser, svelte normally resolves to its server implementation, which renders components to HTML strings instead of running them. The svelte-custom-renderer condition points the exports at the client runtime. With a bundler, add it to the list of resolve conditions. One small extra: our test project needed "type": "module", otherwise Node tried to load the ES module renderer as CommonJS.
What the compiler rejects
Not everything in Svelte makes sense without a browser. The docs list what causes a compile error in these components: bind: on elements other than bind:this, transitions and animations, the legacy on: directive, {@html}, <svelte:head>, <svelte:window>, <svelte:document>, <svelte:body> and css="injected". We tried three of them, and each stopped the build with the code incompatible_with_custom_renderer:
`@html` is not compatible with `customRenderer`
`transition:` is not compatible with `customRenderer`
`bind:` is not compatible with `customRenderer`
`customRenderer` cannot be set in `<svelte:options>` unless the
`experimental.customRenderer` compiler option is enabled
Supported are runes, props, snippets, context, the {#if}, {#each}, {#key} and {#await} blocks, <svelte:boundary>, <svelte:element>, attachments, await expressions and bind: on components. Styles are still scoped with a class like svelte-xyz123 but never injected; whether CSS means anything is up to the renderer. During server-side rendering these components output nothing. In a SvelteKit app they are created in the browser after the page loads, while the page around them is server-rendered and hydrated as usual.
Mixing renderers: a 3D scene in the page, HTML labels in the scene
Things get interesting when renderers nest. A regular page can contain a 3D scene, and the scene can contain HTML labels floating over its objects. Context, props, snippets, error boundaries and reactivity all work across that boundary, according to the docs. The spot where one renderer’s content appears inside another’s tree is called a crossing, and two optional methods handle it. embed is called on the inner renderer and means “I can put my content inside someone else’s tree”. host is called on the outer renderer and makes room for foreign content. Svelte tries embed first, then host, and throws if neither exists. The DOM has neither, so in a mixed app it is always your renderer that builds the bridge. If your renderer will live inside normal web apps, implement embed. If DOM content should appear inside your tree, add host as well.
Where the API came from: Mainmatter, Lynx and React Native
Work on the API predates the release by a long way. In May 2025, Paolo Ricciuti of the consultancy Mainmatter explained in Truly native apps with Svelte? why Svelte needed custom renderers. His starting point was Lynx, a ByteDance-backed framework for native apps with a framework-agnostic core. His comparison was React: React Native can exist because React itself doesn’t care about the DOM, and React-DOM is just one swappable renderer. Mainmatter built a proof of concept Svelte and Lynx integration on an unreleased Svelte build at the time. Note that the function was called createCustomRenderer back then. In the release it is createRenderer, so older examples need updating.
Ricciuti’s pull request #18042 was opened on April 1, 2026 and merged on November 20, 2026, touching 344 files with 7,017 additions and 595 deletions. In the discussion he made clear that a custom renderer alone won’t turn a web app into a mobile app. You still need a target that supports native rendering, and Lynx is a good option. Mobile platforms also have strict rules; in Lynx, as in React Native, text can’t stand without a wrapping text element. His verdict on quick ports: “You can write a custom renderer to map from web elements to lynx elements, but that will probably not work out of the box.” The feature was announced at Svelte Summit in Ljubljana, where the community celebrated Svelte’s tenth birthday.
The limits today
The docs are blunt: the API may change before the experimental flag is removed. Version 5.59.2, five days after the release, already carries a changelog fix that uses comments instead of text nodes for custom renderers. If you write a renderer now, pin the Svelte version and guard every update with tests. There are also no maintained renderer packages from the Svelte team yet. For native mobile, someone has to build and maintain the bridge to Lynx, NativeScript or another platform. And components that rely on bind:value on inputs or on transitions can’t simply be reused.
If you follow the frontend tooling side of things, we recently covered the dev server allow list in Vite 8.4 and the launch of Vite+ 1.0 as a unified JavaScript toolchain. For the Node side of our test, see what changed in Node.js 26.12.0 and 24.22.0.
Our take
Custom renderers are the most interesting Svelte feature since runes, because they free the language from the browser without changing how you write components. Our test shows the foundation already holds: reactivity, lists and events worked on the first try with the example renderer from the docs, and the compiler errors are clear. It is too early for production code while the API is marked experimental and no maintained renderers for 3D, terminals or mobile exist. It is worth trying now, though: for internal tools, terminal UIs, PDF generation or test setups where rendering to plain objects is faster and easier to inspect than a simulated browser. If you build a renderer, give feedback early. While the flag is still there, the API is easiest to shape.


