sveltekit demo

Components

Docvia supports embedding interactive components directly in Markdown using the directive syntax. Components are registered in your config and hydrated on the client.

Directive syntax

Block directive:

:::counter{initial=42 hydrate="client:load"}
:::

Inline directive:

Check the :badge{text="new"} feature.

Registration

Register components in docvia.config.ts:

export default defineConfig({
  components: {
    counter: {
      path: "./src/lib/components/Counter.svelte",
      hydrate: true,
      defaultProps: { initial: 0 },
    },
  },
});

Hydration modes

ModeWhenUse case
hydrate: falseNeverStatic content only
hydrate: trueImmediateInteractive on first paint
client:idleOn idleAfter main thread is free
client:visibleOn intersectionWhen scrolled into view

Live example

Here is an interactive counter embedded via directive:

42

Count

The counter is server-rendered then hydrated client-side.

Creating components

Components are standard Svelte 5 components:

<script lang="ts">
  let { initial = 0 } = $props();
  let count = $state(initial);
</script>

<div class="counter-card">
  <div class="counter-value">{count}</div>
  <div class="counter-controls">
    <button class="btn" onclick={() => count--}>-</button>
    <button class="btn" onclick={() => count = initial}>Reset</button>
    <button class="btn btn-primary" onclick={() => count++}>+</button>
  </div>
</div>