Deploying

Learn how to deploy your Bini.js application to production.

Bini.js can be deployed to any platform that supports Node.js, or exported as static files for static hosting. For all hosting platforms except static export, use the unified npm run deploy command.

Deployment Options

PlatformCommandNotes
Node.js Node.jsnpm run deployDefault — uses bini-server
GitHub Static Exportnpm run buildGitHub Pages, S3, Firebase, Surge
Netlify Netlifynpm run deployAutomated by bini-deploy
Vercel Vercelnpm run deployAutomated by bini-deploy
Cloudflare Cloudflarenpm run deployAutomated by bini-deploy
Deno Deno Deploynpm run deployAutomated by bini-deploy
Unified command: npm run deploy works for Node.js, Netlify, Vercel, Cloudflare, and Deno Deploy. Static export uses npm run build which pre-renders all routes.

One Command to Deploy Anywhere

bini-deploy makes deployment effortless. Simply run:

npm run deploy

When you run npm run deploy, bini-deploy will:

  1. Prompt you to choose your target platform: Web, Windows, macOS, Linux, Android, or iOS
  2. If you choose Web, it prompts for hosting provider: Node.js (default), Netlify, Vercel, Cloudflare, or Deno Deploy
  3. Automatically generates the platform-specific configuration files and entry points
  4. Commits and pushes everything to your GitHub repository

This single command works for all hosting platforms with zero configuration needed:

  • Node.js — Builds and starts the server
  • Netlify — Automatically generates netlify.toml and edge function entry
  • Vercel — Automatically generates vercel.json and serverless function entry
  • Cloudflare — Automatically generates wrangler.toml and worker entry
  • Deno Deploy — Automatically generates server/index.ts entry
Zero config required: bini-deploy automatically detects your project structure, picks the right adapter, and generates platform-specific configuration. No changes to vite.config.ts needed. Learn more at bini-deploy.

Node.jsNode.js Server

The default deployment option. Bini.js uses bini-server — a zero-dependency production server.

npm run deploy

Your app will be served at the port specified by PORT (default: 3000).

Platforms

  • Railway — Auto-detects Node.js, just connect your repo
  • Render — Set build command to npm run deploy and start to npm start
  • Fly.io — Use the Node.js builder
  • VPS — Use pm2 to keep the server running
bini-server features: ETag support, 30s timeouts, 10MB body limit, graceful shutdown, and automatic port increment.

NetlifyNetlify

Deploying to Netlify is completely automated with bini-deploy. No configuration needed.

npm run deploy

bini-deploy automatically generates:

  • netlify.toml — Build and edge function configuration
  • netlify/edge-functions/api.ts — API route handler for Edge Functions
Important: Netlify Edge Functions run on Deno, not Node.js. Node-specific packages like nodemailer, fs, or path will not work. Use Web API alternatives.

VercelVercel

Deploying to Vercel is completely automated with bini-deploy. No configuration needed.

npm run deploy

bini-deploy automatically generates:

  • vercel.json — Routing and build configuration
  • api/index.ts — Serverless function entry point

CloudflareCloudflare Workers

Deploying to Cloudflare Workers is completely automated with bini-deploy. No configuration needed.

npm run deploy

bini-deploy automatically generates:

  • wrangler.toml — Worker configuration
  • worker.ts — Worker entry point with API routes

DenoDeno Deploy

Deploying to Deno Deploy is completely automated with bini-deploy. No configuration needed.

npm run deploy

bini-deploy automatically generates:

  • server/index.ts — Deno Deploy entry point

GitHubStatic Export

For static hosting, npm run build pre-renders every route to static HTML. This is the only deployment method that doesn't use npm run deploy.

npm run build

The pre-rendered files will be in the dist/ folder. Suitable for:

  • GitHub Pages
  • Amazon S3
  • Firebase Hosting
  • Cloudflare Pages (static mode)
  • Netlify (static mode)
  • Vercel (static mode)

GitHub Pages

Set the base option in vite.config.ts if deploying to a subpath:

// vite.config.ts
export default defineConfig({
  base: '/your-repo-name/',
})

Then deploy the dist/ folder to GitHub Pages.

Pre-rendering: npm run build pre-renders all static routes to HTML and creates shell pages for dynamic routes. The client hydrates on load. No separate export command needed.

Platform Comparison

PlatformAPI RuntimeStatic RoutesDynamic RoutesDeploy Command
Node.js Node.jsNode.jsnpm run deploy
Netlify NetlifyDeno (Edge)npm run deploy
Vercel VercelEdgenpm run deploy
Cloudflare CloudflareWorkersnpm run deploy
Deno Deno DeployDenonpm run deploy
GitHub Static ExportN/Avia shell pagesnpm run build

Environment Variables in Production

Set environment variables through your hosting platform's dashboard:

PlatformHow to Set
Node.js Node.jsUse .env file or system environment variables
Netlify NetlifySite settings → Environment variables
Vercel VercelProject settings → Environment Variables
Cloudflare Cloudflarewrangler.toml or dashboard
Deno Deno DeployProject settings → Environment Variables
Never commit .env files with secrets to your repository. Use platform environment variables for production.

Best Practices

  • Test builds locally — Run npm run build and npm run preview before deploying.
  • Use environment variables — Keep configuration separate from code.
  • Set up CI/CD — Automate deployments with GitHub Actions or similar.
  • Monitor your app — Use platform analytics to track performance.
  • Use a custom domain — Configure SSL for secure connections.