Skip to content

Deploy SvelteKit

Stackpad auto-detects SvelteKit applications and deploys them as Node.js servers.

Quick deploy

  1. Push your SvelteKit project to GitHub
  2. Create a new project on Stackpad and select your repo
  3. Stackpad detects @sveltejs/kit in your dependencies
  4. Your app is live at your-project.your-org.stackpad.eu

Configuration

Node adapter

SvelteKit needs the Node.js adapter for server deployment. Install it:

Terminal window
npm install -D @sveltejs/adapter-node

Update svelte.config.js:

import adapter from '@sveltejs/adapter-node';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter(),
},
};
export default config;

The default port is 3000. Stackpad runs the built server from the build directory.

Environment variables

SvelteKit uses the $env modules:

// Server-side only (never exposed to client)
import { DATABASE_URL } from '$env/static/private';
// Available in client-side code
import { PUBLIC_API_URL } from '$env/static/public';

PUBLIC_* variables are embedded at build time (like Next.js NEXT_PUBLIC_*). Set them in the Stackpad dashboard before deploying.

Database

Add PostgreSQL and redeploy:

src/lib/server/db.ts
import { DATABASE_URL } from '$env/static/private';
import { Pool } from 'pg';
export const pool = new Pool({ connectionString: DATABASE_URL });

What’s next?