Deploying

Build once, deploy to Node.js, Vercel, or Cloudflare. Zero configuration needed — NukeJS detects the environment automatically.

Build for production

terminalbash
npm run build

This produces a dist/ directory ready to run:

dist/bash
dist/
├── api/                    # Bundled API route handlers (.mjs)
├── pages/                  # Bundled SSR page handlers (.mjs)
├── static/
│   ├── __react.js          # React runtime
│   ├── __n.js              # NukeJS client runtime
│   ├── __client-component/ # "use client" component bundles
│   └── ...                 # Copied from app/public/
├── manifest.json           # Route dispatch table
└── index.mjs               # HTTP server entry point

Node.js

terminalbash
node dist/index.mjs

Set the port with the PORT env variable:

terminalbash
PORT=8080 ENVIRONMENT=production node dist/index.mjs

PM2 (process manager)

terminalbash
npm install -g pm2
pm2 start dist/index.mjs --name nukejs-app
pm2 save && pm2 startup

Vercel

Import your GitHub repo in the Vercel dashboard — no additional configuration needed. NukeJS auto-detects the Vercel build environment and outputs to .vercel/output/.

1

Push your project to GitHub

2

Go to vercel.com/new and import the repository

3

Click Deploy — Vercel runs npm run build and deploys automatically

Public files are CDN-hosted on VercelEverything in app/public/ lands on Vercel's CDN — served globally with zero latency and no function invocations.

Cloudflare

Import your GitHub repo in the Cloudflare dashboard — no additional configuration needed. NukeJS auto-detects the Cloudflare build environment and outputs to .cloudflare/output/.

1

Push your project to GitHub

2

Go to dash.cloudflare.com, open Workers & Pages and connect your repository

3

Click Deploy — Cloudflare runs npm run build and deploys automatically

The build output:

.cloudflare/output/bash
.cloudflare/output/
├── _worker.mjs     # Single ESM Worker (all routes bundled)
└── static/
    ├── __n.js                  # NukeJS client runtime
    ├── __client-component/     # "use client" component bundles
    └── ...                     # Copied from app/public/
Public files are CDN-hosted on CloudflareEverything in app/public/ lands on Cloudflare's global CDN — served with zero latency and no Worker invocations.
ℹ️
Pages vs WorkersFor Cloudflare Pages, set your build output directory to .cloudflare/output in the dashboard. For standalone Workers via wrangler deploy, static assets are inlined into the Worker bundle automatically — no extra step needed.

Environment variables

Set secrets in your hosting platform's dashboard, or use a .env file for Node deployments. Access them in server code via process.env:

server/db.tstypescript
const uri = process.env.DATABASE_URL
if (!uri) throw new Error('DATABASE_URL is required')
🚫
Never read secrets in client componentsEnvironment variables accessed in "use client" files get bundled into the browser JavaScript and become public. Only read secrets in server components and API routes.