Quick Start
Requirements
- Node.js
^20.19.0or>=22.12.0 - Svelte 5, SvelteKit 2 (
2.65.1or later) or SvelteKit 3, and Vite 8 - pnpm 10 is recommended; npm, Yarn, and Bun are also supported by the create command
Creating a project
Run the command for your package manager.
PNPM first
The repository and generated templates are tested with pnpm 10.
npm create @sveltepress@latest sh
Adding to an existing sveltekit project
Install vite plugin package
npm install --save @sveltepress/vite sh
Replace sveltekit plugin in vite.config.(js|ts)
vite.config.(js|ts)
-
+
-
+
import { } from '@sveltejs/kit/vite'
import { } from '@sveltepress/vite'
import { } from 'vite'
const = ({
: [
(),
(),
],
})
export default ts
Remove the original
sveltekit() pluginsveltepress() already sets up SvelteKit for you. Keeping both sveltekit() and sveltepress() in plugins compiles every Svelte file twice and crashes the dev server with Expected token }.
Pass your SvelteKit config through sveltepress()
SvelteKit 3 support
SvelteKit 3 no longer reads svelte.config.js, and refuses to start while one exists. Move its options, including everything that was under kit, into sveltepress({ svelteKitOptions }), then delete svelte.config.js. Sveltepress adds the '.md' extension for you.
vite.config.ts
import from '@sveltejs/adapter-static'
import { } from '@sveltejs/vite-plugin-svelte'
import { } from '@sveltepress/vite'
import { } from 'vite'
export default ({
: [
({
: {
: [()],
: ({
: 'dist',
}),
},
}),
],
}) ts
Still on SvelteKit 2?
SvelteKit 2 accepts svelteKitOptions too. Alternatively, keep svelte.config.js and add '.md' to its extensions:
svelte.config.js
-
+
import from '@sveltejs/adapter-static'
import { } from '@sveltejs/vite-plugin-svelte'
/**
* @type {import('@sveltejs/kit').Config}
*/
const = {
: ['.svelte'],
: ['.svelte', '.md'], // add .md here
: [()],
: {
: ({
: 'dist',
}),
},
}
export default ts
Upgrading to SvelteKit 3
- Upgrade
@sveltejs/kitto^3.0.0and your adapter to its SvelteKit 3 release, for example@sveltejs/adapter-static^4.0.0. SvelteKit 3 needs Node.js>=22.17. - Run
npx sv migrate sveltekit-3to migrate your own code, such as$app/stores,basefrom$app/paths, and$libimports. - Make sure your SvelteKit config lives in
sveltepress({ svelteKitOptions })as shown above. The migration movessvelte.config.jsinto asveltekit(...)call in your Vite config: move that object intosvelteKitOptionsand remove thesveltekit(...)plugin.
Sveltepress itself needs no other change. Keep these in mind:
$libis replaced by the#libsubpath import. Version management tracks#lib/imports like$lib/ones, so if your manifest shares$lib/**, add#lib/**tocontent.sharedas well.- The Default Theme
pwaoption relies on@vite-pwa/sveltekit, which does not support SvelteKit 3 yet. On SvelteKit 3 no service worker is generated, and the build prints a warning.