Deploy guide
How to deploy SvelteKit to GitHub Pages
The base path, a workflow file to copy and the one setting to switch: SvelteKit on GitHub Pages, built on every push.
Checked 16 October 2026
In short
The settings
- Pages source
- Build
- Folder it publishes
- Live at
Step by step
Set it up
- 1
Set up SvelteKit for a static build
Install the static adapter (
npm i -D @sveltejs/adapter-static), use it in your config, and addexport const prerender = true;tosrc/routes/+layout.jsso every page is built to a file.vite.config.js import adapter from '@sveltejs/adapter-static'; import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; export default defineConfig({ plugins: [ sveltekit({ adapter: adapter(), }), ], }); - 2
Set the base path
A GitHub Pages project site lives in a subfolder, USERNAME.github.io/REPO, so the build has to know that folder's name.
Give the adapter a
404.htmlfallback and read the base path from theBASE_PATHvariable the workflow sets.vite.config.js sveltekit({ adapter: adapter({ fallback: '404.html' }), paths: { base: process.env.BASE_PATH ?? '' }, }), - 3
Add the workflow
Create
.github/workflows/deploy.ymlin the repository with the file below. It builds the site on every push to main and publishes the result..github/workflows/deploy.yml name: Deploy to GitHub Pages on: push: branches: [main] workflow_dispatch: permissions: contents: read pages: write id-token: write concurrency: group: pages cancel-in-progress: false jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v7 with: node-version: lts/* cache: npm - id: pages uses: actions/configure-pages@v6 - run: npm ci - name: Build run: npm run build env: BASE_PATH: "/${{ github.event.repository.name }}" - uses: actions/upload-pages-artifact@v5 with: path: build deploy: needs: build runs-on: ubuntu-latest environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - id: deployment uses: actions/deploy-pages@v5 - 4
Switch Pages to GitHub Actions
In the repository on GitHub, open the Pages settings and set the source to GitHub Actions. This is a one-time switch.
Settings→Pages→Build and deployment→Source: GitHub Actions
- 5
Push, then open your site
Commit and push to main. The Actions tab shows the build; when it turns green, the site is at https://USERNAME.github.io/REPO/. Every push after that deploys again.
Good to know
Common snags
- SvelteKit 2 keeps the adapter in
svelte.config.jsunderkit.adapter; SvelteKit 3 moved it into thesveltekit()plugin invite.config.js, as shown here. The options are the same. - The workflow uses npm. With pnpm or Yarn, change the install line and the cache setting to match.
Stuck? The usual problems, solved
Questions
Before you start
Why does my site load without its styles?
The pages are looking for their files at the root of USERNAME.github.io instead of in /REPO/. Check the base path setting in step one matches the repository name exactly, including capitals.
Is GitHub Pages free?
Free for public repositories. Private repositories need a paid GitHub plan. A Pages site is public, even when it is built from a private repository.
How do I use my own domain?
Add it in Settings → Pages → Custom domain, then add the DNS records at your registrar (our custom domain guides have them per registrar). With your own domain the site is at the root again, so remove the base path setting.
Next step: connect your own domain to GitHub Pages.
Rather skip git and build settings?
Build on your computer with npm run build, then drop the build folder (or a zip of it) on 99helpers. It's online at its own address in seconds, with no repository, workflow or base path to set up. Passwords, analytics, your own domain and AI editing are built in.
Or skip the setup
Drop it in. It's online in seconds.
A file, a folder or a whole site: 99helpers puts it online at its own address, with no git, no build settings and no DNS to start with. Add your own domain whenever you're ready.