Skip to main content
The @sveltejs/adapter-node adapter generates a standalone Node server for your SvelteKit application.

Installation

Usage

Add the adapter to your svelte.config.js:

Configuration options

These options are defined in the adapter source code:

out

The directory where the server build output will be written.

precompress

Enables precompression of assets using gzip and brotli. This is enabled by default.
From the adapter implementation:

envPrefix

A prefix for environment variables. For example, if you set envPrefix: 'MY_APP_', then environment variables like MY_APP_HOST and MY_APP_PORT will be used.

Deployment

After building your app, the output directory contains everything needed to run your application:
1

Build the app

2

Run the server

Environment variables

The adapter recognizes several environment variables to configure the server at runtime:
Here’s how environment variables are used in the handler:

Build output structure

The adapter generates the following directory structure:

Platform object

The adapter provides access to the raw Node.js request object via event.platform:
The platform.req object is the raw Node.js IncomingMessage object from the http module.

Advanced usage

You can use the generated handler.js as middleware in your own Node server:
The adapter bundles dependencies using Rollup, but dependencies listed in package.json are kept as external imports. Make sure to install production dependencies before deploying.