Deploying SvelteKit Applications
This guide covers the deployment process for SvelteKit applications, including static hosting and server-side deployment options.
Static Site Deployment
If you are using the @sveltejs/adapter-static, you can deploy your application to any static hosting service.
Vercel
Login with the Vercel CLI:
pnpm dlx vercel loginDeploy:
pnpm dlx vercel
Netlify
Login to Netlify:
pnpm dlx netlify-cli loginDeploy:
pnpm dlx netlify-cli deploy --prod
GitHub Pages
For a repository page, configure a base path and publish the static build directory through GitHub Pages artifacts:
- Set
site.basePathinmarkstatic.config.js, for example/my-repo. - Build with
pnpm build. - Upload
buildwithactions/upload-pages-artifact. - Deploy with
actions/deploy-pages.
Scaffolded github-pages projects include this workflow automatically.
Server-Side Deployment
For server-side deployment, you need a suitable adapter like @sveltejs/adapter-node.
Node.js Server
Install Node adapter:
pnpm add -D @sveltejs/adapter-nodeConfigure SvelteKit:
Update
svelte.config.js:import adapter from '@sveltejs/adapter-node'; export default { kit: { adapter: adapter() } };Build and Start:
pnpm build node build
Docker
Create a Dockerfile:
FROM node:22-alpine WORKDIR /app RUN corepack enable COPY package.json pnpm-lock.yaml ./ RUN pnpm install --frozen-lockfile COPY . . RUN pnpm build EXPOSE 3000 CMD ["node", "build"]Build Docker Image:
docker build -t sveltekit-app .Run Docker Container:
docker run -p 3000:3000 sveltekit-app
Additional Resources
These steps should help you deploy your SvelteKit applications effectively.