Skip to content
For agents
Browse guides

SvelteKit

Use the Node adapter for server-rendered pages, actions and API endpoints.

Open Markdown

Deploy a SvelteKit app, with server-rendered pages, form actions and API endpoints, using the Node adapter.

Configure the Node adapter

Use @sveltejs/adapter-node in svelte.config.js with kit.adapter: adapter(). The build produces a build directory; node build starts the server. It needs node_modules next to it at runtime.

Set HOST=0.0.0.0 and PORT=3000. Also tell SvelteKit your app's public https:// address, or form submissions are rejected. In SvelteKit 2, set the ORIGIN environment variable; in SvelteKit 3, set kit.paths.origin.

Add src/routes/health/+server.ts returning 200, and set the app's health path to /health. After deploying, submit a form as well as opening a page. If the form fails with an origin error, fix the address above; don't turn off CSRF checks.

Build with a Dockerfile

This Dockerfile uses npm. For pnpm, Yarn or Bun, copy that tool's lockfile instead and change the install line.

Code
FROM node:24.21.0-bookworm-slim@sha256:d6aa754f16b3197301076f047b5def2f02ea1dbbc2ca920407d46d7ec7f87b20 AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:24.21.0-bookworm-slim@sha256:d6aa754f16b3197301076f047b5def2f02ea1dbbc2ca920407d46d7ec7f87b20
WORKDIR /app
ENV NODE_ENV=production HOST=0.0.0.0 PORT=3000
COPY --from=build --chown=10001:10001 /app ./
USER 10001:10001
EXPOSE 3000
CMD ["node", "build"]

Deploy the app

Save the Dockerfile at the source root. In Configuration, set the port to 3000 and the health path to the route you added above. Add a .dockerignore that excludes .env*, .git, node_modules and local build output, then deploy:

Shell
smolcloud deploy APP_ID .

Open the address it prints. You can also call a route from the CLI:

Shell
smolcloud request APP_ID /

You don't have to write a Dockerfile: see Automatic builds. To add a database or file storage, see Databases and files.

See also: SvelteKit Node adapter.