Deploying SvelteKit
SvelteKit runs on slew's Node servers through the official Node adapter.
Build with adapter-node
npm i -D @sveltejs/adapter-node
// svelte.config.js
import adapter from '@sveltejs/adapter-node'
export default {
kit: { adapter: adapter() },
}
npm run build produces build/ with index.js as the entry. It reads PORT from the environment and binds 0.0.0.0 by default — exactly what the platform injects, so no host configuration is needed.
Push to GitHub — detected automatically
Connect the repo and every push deploys. The builder recognizes an adapter-node build — the dependencies plus build/index.js — and assembles the server artifact for you: the build as the server bundle, your package.json next to the entry (the build is ESM in .js files and needs "type": "module"), a production node_modules from your lockfile (npm ci --omit=dev, so commit a package-lock.json), and build/client/ served straight from the CDN. Leave the build settings at their defaults.
Set ORIGIN so SvelteKit knows its public URL (form actions and absolute URLs depend on it), then connect:
slew env set ORIGIN=https://<project>.slew.cloud
slew git connect owner/repo
Fingerprinted assets under /_app/* are served from static/ by the CDN; everything else hits the SvelteKit server. Keep production dependencies lean — the deploy caps at 10,000 files, node_modules included.
The manual artifact (fallback and reference)
An explicit slew.json in the output directory always wins over detection. Two runtime needs shape the artifact:
- The build is ESM in
.jsfiles, so Node needs a"type": "module"package.jsonnext to the entry — copy the project's into the artifact. - Packages in your
dependenciesstay external and resolve fromnode_modulesat runtime (devDependencies are bundled into the build). Ship a prunednode_modules— via git push-to-deploy, becauseslew deploynever packsnode_modules.
slew.json { "server": "server/index.js" }
server/ = build
server/package.json the project package.json ("type": "module")
server/node_modules/ production dependencies
static/ = build/client — served directly by the CDN
Assembly (scripts/build-slew.sh or an npm script):
npm run build
npm ci --omit=dev
rm -rf out && mkdir out
cp -r build out/server
cp package.json out/server/package.json
cp -r node_modules out/server/node_modules
cp -r build/client out/static
printf '{ "server": "server/index.js" }\n' > out/slew.json
Connect with the assembly as the build command:
slew git connect owner/repo --build-cmd "bash scripts/build-slew.sh" --output out
slew deploy out also works — but only when the app has nothing in dependencies, since the CLI strips node_modules. With an empty dependencies the build is fully self-contained and you can skip the node_modules copy.