@sveltejs/adapter-node adapter generates a standalone Node server for your SvelteKit application.
Installation
Usage
Add the adapter to yoursvelte.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.envPrefix
A prefix for environment variables. For example, if you setenvPrefix: '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:Build output structure
The adapter generates the following directory structure:Platform object
The adapter provides access to the raw Node.js request object viaevent.platform:
The
platform.req object is the raw Node.js IncomingMessage object from the http module.Advanced usage
You can use the generatedhandler.js as middleware in your own Node server: