svelte-prerender-example

Svelte Prerender Example

Example of how to prerender Svelte app at build-time

Prerender Svelte app at build-time

:warning: I'd recommend you to use rollup-plugin-svelte-ssr instead. It uses the same approach but it's easier to use.

This is an example how to prerender Svelte app

Get started

Install the dependencies

npm install

Build

npm run build

Run

npm run serve

Navigate to localhost:5000. You should see your app running

How it works

Rollup config consists of two separate configs:

The first config used to build usual iife bundle with app.

The second config used to build root component as SSR component. When SSR component bundled, Rollup executes script prerender.js, which uses SSR Component API to get HTML and CSS.

Remarks

It's experimental example. Maybe there is a more simple way.

Top categories

Loading Svelte Themes