sveltekit demo

Rendering

Docvia compiles Markdown into a RenderOutput tree. page.data.load() returns it as content, and the Renderer component renders it in your Svelte application.

Basic usage

<script>
  import { Renderer } from "@docvia/core/svelte";
  let { data } = $props();
</script>

<Renderer nodes={data.page.content} />

The Renderer is a Svelte 5 component using runes syntax. No client-side JavaScript is shipped unless your content contains interactive components.

Component registry

For interactive components embedded via directives, pass a registry:

<Renderer nodes={data.page.content} registry={registry} />

The registry resolves directive names to Svelte components. defineRegistry() in src/lib/registry.ts builds it from the components field in docvia.config.ts:

import { registry } from "#lib/registry.ts";

Renderer also switches tabbed code groups (fences with tab="...", :::code-group, or an npm fence) without extra setup.

Renderer props

PropTypeRequiredDescription
nodesRenderOutput | RenderOutput[]YesCompiled page content
registryComponentRegistryNoComponent resolver for directives

RenderOutput types

The compiled output is a tree of typed nodes:

KindDescription
elementHTML element (div, p, h2, ...)
textPlain text content
htmlRaw HTML (syntax-highlighted code)
componentInteractive component placeholder
fragmentGrouping node with children

Differences from React

The Svelte renderer does not yet support the components prop for tag-level overrides (e.g., replacing <a> or <img> globally). This is a React-specific feature. In Svelte, customize element rendering by extending the Renderer or by rewriting the output tree at build time with createSvelteRenderer({ transform }).