Skip to main content
Syntax

984: How to Make a DOM Library Render Anything w/ Paolo Ricciuti

49 min episode · 2 min read
·

Episode

49 min

Read time

2 min

AI-Generated Summary

Key Takeaways

  • Svelte compiler output: Developers can inspect exactly what Svelte compiles their components into by opening the JS output tab in the Svelte playground, or using the "show compiled code" command in the VS Code extension. Hovering over code with the JS output tab open uses source maps to show which Svelte code maps to which compiled JavaScript line.
  • CSP-safe compilation via fragments: Svelte's compiler now accepts a `fragments: true` option that replaces the default `innerHTML` template approach with explicit `document.createElement` and `document.setAttribute` calls. This resolves Content Security Policy violations that blocked Svelte for teams with strict CSP rules preventing any form of innerHTML usage.
  • Custom renderer architecture: Building a Svelte custom renderer requires defining a module that exports functions telling Svelte how to create, update, and delete elements in a target environment. Svelte calls these functions without knowing the target, making the renderer a translation layer — a `p` tag call becomes whatever the target platform's equivalent element is.
  • Single runtime over dual runtime: An earlier approach split Svelte into two separate runtimes — one for the DOM, one for custom renderers — but this created unsustainable code duplication where bug fixes required identical changes in two files. The current approach uses one runtime with conditional branching: if a custom renderer exists, invoke it; otherwise, use the optimized DOM shortcut.
  • Sponsorship-driven development: The custom renderer project at svelte-custom-renderers.com is actively seeking company sponsors to fund continued development. Main Matter funded three months of full-time work previously. Companies building native apps, WebGL tools, or terminal UIs with Svelte are the target sponsors, and a community member has already extended the existing POC to run on Hermes, React Native's JavaScript engine.

What It Covers

Paolo Ricciuti, Svelte maintainer at Main Matter, explains how Svelte's DOM-coupled architecture makes custom renderers difficult to build, and details the technical work underway to enable Svelte to render to native mobile apps, terminals, WebGL, and other non-browser targets via a new custom renderer API.

Key Questions Answered

  • Svelte compiler output: Developers can inspect exactly what Svelte compiles their components into by opening the JS output tab in the Svelte playground, or using the "show compiled code" command in the VS Code extension. Hovering over code with the JS output tab open uses source maps to show which Svelte code maps to which compiled JavaScript line.
  • CSP-safe compilation via fragments: Svelte's compiler now accepts a `fragments: true` option that replaces the default `innerHTML` template approach with explicit `document.createElement` and `document.setAttribute` calls. This resolves Content Security Policy violations that blocked Svelte for teams with strict CSP rules preventing any form of innerHTML usage.
  • Custom renderer architecture: Building a Svelte custom renderer requires defining a module that exports functions telling Svelte how to create, update, and delete elements in a target environment. Svelte calls these functions without knowing the target, making the renderer a translation layer — a `p` tag call becomes whatever the target platform's equivalent element is.
  • Single runtime over dual runtime: An earlier approach split Svelte into two separate runtimes — one for the DOM, one for custom renderers — but this created unsustainable code duplication where bug fixes required identical changes in two files. The current approach uses one runtime with conditional branching: if a custom renderer exists, invoke it; otherwise, use the optimized DOM shortcut.
  • Sponsorship-driven development: The custom renderer project at svelte-custom-renderers.com is actively seeking company sponsors to fund continued development. Main Matter funded three months of full-time work previously. Companies building native apps, WebGL tools, or terminal UIs with Svelte are the target sponsors, and a community member has already extended the existing POC to run on Hermes, React Native's JavaScript engine.

Notable Moment

Paolo described building a working to-do app rendered inside a Lynx native application using a minimal Svelte custom renderer POC — a Svelte component with standard tags producing a fully functional native UI, with no browser or DOM involved anywhere in the rendering pipeline.

Know someone who'd find this useful?

You just read a 3-minute summary of a 46-minute episode.

Get Syntax summarized like this every Monday — plus up to 2 more podcasts, free.

Pick Your Podcasts — Free

Keep Reading

More from Syntax

We summarize every new episode. Want them in your inbox?

Similar Episodes

Related episodes from other podcasts

This podcast is featured in Best Cybersecurity Podcasts (2026) — ranked and reviewed with AI summaries.

You're clearly into Syntax.

Every Monday, we deliver AI summaries of the latest episodes from Syntax and 192+ other podcasts. Free for up to 3 shows.

Start My Monday Digest

No credit card · Unsubscribe anytime