Node.js
View as MarkdownThe Node.js adapter builds your application into a standalone Node.js server. This is suitable for deploying to VPS providers (DigitalOcean, Linode), PaaS (Heroku, Railway, Render), or custom infrastructure.
Usage
The Node adapter ships inside @neutron-build/core and is selected at build time via the CLI's --preset flag — no separate install needed. For a long-running Node server, use the docker preset (which produces a Node server.mjs you can run directly without containerizing).
-
Build with the Docker preset (produces a standalone Node server):
npx @neutron-build/cli build --preset docker -
Run the generated server:
node dist/server.mjs
neutron-ts start
neutron-ts build also compiles everything the production server loads per
request (route modules, layouts, not-found, resource routes and
src/middleware.ts) into a server bundle at dist/server/start/, recorded
in dist/.neutron-server-bundle.json. neutron-ts start (and
createServer) loads it natively: no source is transformed at boot and no
Vite server is created. The boot banner says which source it used
(Modules: prebuilt server bundle). Externals still resolve from
node_modules, so deploy dist/ together with your installed dependencies.
The bundle is the code as of the last build. When it cannot stand in for the
source (built for another runtime, or missing a route added since), the
server warns and transforms routes through Vite at runtime instead. A
createServer-based development server should pass serverBundle: false
so a bundle left in dist/ by an earlier build does not serve stale code.
neutron-ts preview vs. the production artifact
npx neutron-ts preview starts a local preview server that runs SSR through the
dev toolchain (Vite + your src/ files). It is convenient for a quick local
check, but it is not the artifact you deploy:
- Preview needs
src/and your dev dependencies present, and pulls Vite at runtime unless the build left a server bundle indist/. - The deployed artifact is the preset-generated entry (e.g.
dist/server.mjsfrom--preset docker), which bundles everything and ships no Vite — it runs fromdist/alone.
To validate what actually deploys, build with a preset and run the generated
server (the two commands above) rather than relying on preview.