SvelteKit SPA
Copy it into a new project:
pnpm dlx degit antstanley/blogwright/examples/sveltekit-spa my-siteSvelteKit with adapter-static and SSR off: one shell page, routed in the browser.
| Framework | Mode | Blogwright config | Source |
|---|---|---|---|
SvelteKit + adapter-static |
Single-page app | paths.dist, spa |
examples/sveltekit-spa |
Deploy it
Section titled “Deploy it”-
Copy the example and start a repository:
Terminal window pnpm dlx degit antstanley/blogwright/examples/sveltekit-spa my-sitecd my-site && git init -
Set
siteNameandregioninconfig/production.jsonc. -
Add Blogwright, then commit everything, including
pnpm-lock.yaml- the builder installs with--frozen-lockfile:Terminal window pnpm add -D blogwrightgit add -A && git commit -m "Start from the blogwright example" -
Create the infrastructure:
pnpm exec blogwright bootstrap -
Build and publish:
pnpm exec blogwright deploy
What matters
Section titled “What matters”config/production.jsonc-paths.distisbuildandspaistrue. Setspabefore the firstbootstrap: the error-page mapping is applied when the distribution is created.vite.config.js-adapter-staticwithfallback: 'index.html'.spa: trueanswers every path with no object in S3 with/index.html(status200), so the fallback must beindex.html.src/routes/+layout.js-ssr = false: pages render in the browser only.
The files
Section titled “The files”// Blogwright config for this example. Paths are relative to the repository// root, so they assume this directory IS the repository - see README.md.{ "region": "us-east-1", "siteName": "sveltekit-spa", "paths": { "dist": "build" }, // Set before the first bootstrap: misses answer /index.html with a 200. "spa": true,}import adapter from '@sveltejs/adapter-static';import { sveltekit } from '@sveltejs/kit/vite';import { defineConfig } from 'vite';
export default defineConfig({ plugins: [ sveltekit({ // One shell page for every route. Blogwright's `spa: true` answers any // path with no object in S3 with /index.html, so the fallback must be // index.html. adapter: adapter({ fallback: 'index.html' }), }), ],});// Render in the browser only; the router takes over from index.html.export const ssr = false;{ "name": "blogwright-example-sveltekit-spa", "private": true, "type": "module", "packageManager": "pnpm@11.25.0", "scripts": { "dev": "vite dev", "build": "vite build", "preview": "vite preview" }, "devDependencies": { "@sveltejs/adapter-static": "^4.0.0", "@sveltejs/kit": "^3.0.1", "svelte": "^5.57.2", "vite": "^8.3.4" }}Related pages
Section titled “Related pages”- Single-page apps - how
spamode answers unknown paths - Examples overview - every example, and the conventions they share