guide
advanced
ssr
SSR in R3 is experimental
For SSR, it is recommended to use Routify with Vite and @roxi/routify/vite-plugin.
To use SSR with Vite
- Enable
ssr.enablein Routify’s Vite plugin andcompilerOptions.hydratablein Svelte’s Vite plugin.
// vite.config.js
...
plugins: [
routify({ ssr: { enable: true } })
svelte({ compilerOptions: { hydratable: true } })
]
- Enable
hydratein your app.
// src/main.js
...
new App({ target: document.body, hydrate: true })
Prerendering
Apps can be prerendered by enabling ssr.prerender in Routify’s Vite plugin.