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.jsnpm run deployDefault - uses bini-server
Static Exportnpm run buildGitHub Pages, S3, Firebase, Surge
Netlifynpm run deployAutomated by bini-deploy
Vercelnpm run deployAutomated by bini-deploy
Cloudflarenpm run deployAutomated by bini-deploy
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:

>_Terminal
$ npm run deploy

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

1Run npm run deploy
2Choose a target
3Config is generated
4Pushed to GitHub

Step 1 - Choose the target platform

bini-deploy asks which platform you want to deploy to. Choose Web for any hosting provider:

>_Terminal
? Select your target platform:
> Web
Windows
macOS
iOS
Linux
Android
 
↑↓ navigate • ⏎ select

Step 2 - Choose the hosting provider

If you picked Web, bini-deploy then asks for the hosting provider. The highlighted choice below matches the section you're reading:

>_Terminal
? Select hosting provider:
> Node.js (default - bini-server)
Netlify
Vercel
Cloudflare Workers
Deno Deploy
 
↑↓ navigate • ⏎ select
  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.js Server

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

>_Terminal
$ npm run deploy

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

.env
# .env
PORT=3000

Step 1 - Choose the target platform

bini-deploy asks which platform you want to deploy to. Choose Web for any hosting provider:

>_Terminal
? Select your target platform:
> Web
Windows
macOS
iOS
Linux
Android
 
↑↓ navigate • ⏎ select

Step 2 - Choose the hosting provider

If you picked Web, bini-deploy then asks for the hosting provider. The highlighted choice below matches the section you're reading:

>_Terminal
? Select hosting provider:
> Node.js (default - bini-server)
Netlify
Vercel
Cloudflare Workers
Deno Deploy
 
↑↓ navigate • ⏎ select

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.

Netlify

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

>_Terminal
$ npm run deploy

bini-deploy automatically generates:

netlify.toml
netlify
edge-functions
api.ts
  • netlify.toml - Build and edge function configuration
  • netlify/edge-functions/api.ts - API route handler for Edge Functions

Step 1 - Choose the target platform

bini-deploy asks which platform you want to deploy to. Choose Web for any hosting provider:

>_Terminal
? Select your target platform:
> Web
Windows
macOS
iOS
Linux
Android
 
↑↓ navigate • ⏎ select

Step 2 - Choose the hosting provider

If you picked Web, bini-deploy then asks for the hosting provider. The highlighted choice below matches the section you're reading:

>_Terminal
? Select hosting provider:
Node.js (default - bini-server)
> Netlify
Vercel
Cloudflare Workers
Deno Deploy
 
↑↓ navigate • ⏎ select
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.

Vercel

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

>_Terminal
$ npm run deploy

bini-deploy automatically generates:

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

Step 1 - Choose the target platform

bini-deploy asks which platform you want to deploy to. Choose Web for any hosting provider:

>_Terminal
? Select your target platform:
> Web
Windows
macOS
iOS
Linux
Android
 
↑↓ navigate • ⏎ select

Step 2 - Choose the hosting provider

If you picked Web, bini-deploy then asks for the hosting provider. The highlighted choice below matches the section you're reading:

>_Terminal
? Select hosting provider:
Node.js (default - bini-server)
Netlify
> Vercel
Cloudflare Workers
Deno Deploy
 
↑↓ navigate • ⏎ select

Cloudflare Workers

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

>_Terminal
$ npm run deploy

bini-deploy automatically generates:

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

Step 1 - Choose the target platform

bini-deploy asks which platform you want to deploy to. Choose Web for any hosting provider:

>_Terminal
? Select your target platform:
> Web
Windows
macOS
iOS
Linux
Android
 
↑↓ navigate • ⏎ select

Step 2 - Choose the hosting provider

If you picked Web, bini-deploy then asks for the hosting provider. The highlighted choice below matches the section you're reading:

>_Terminal
? Select hosting provider:
Node.js (default - bini-server)
Netlify
Vercel
> Cloudflare Workers
Deno Deploy
 
↑↓ navigate • ⏎ select

Deno Deploy

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

>_Terminal
$ npm run deploy

bini-deploy automatically generates:

server
index.ts
  • server/index.ts - Deno Deploy entry point

Step 1 - Choose the target platform

bini-deploy asks which platform you want to deploy to. Choose Web for any hosting provider:

>_Terminal
? Select your target platform:
> Web
Windows
macOS
iOS
Linux
Android
 
↑↓ navigate • ⏎ select

Step 2 - Choose the hosting provider

If you picked Web, bini-deploy then asks for the hosting provider. The highlighted choice below matches the section you're reading:

>_Terminal
? Select hosting provider:
Node.js (default - bini-server)
Netlify
Vercel
Cloudflare Workers
> Deno Deploy
 
↑↓ navigate • ⏎ select

Static Export

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

>_Terminal
$ 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { biniroute } from 'bini-router'

export default defineConfig({
  base: '/your-repo-name/',
  plugins: [react(), biniroute()],
})

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 RuntimeStaticDynamicCommand
Node.jsNode.js✓✓npm run deploy
NetlifyDeno (Edge)✓✓npm run deploy
VercelEdge✓✓npm run deploy
CloudflareWorkers✓✓npm run deploy
Deno DeployDeno✓✓npm run deploy
Static ExportN/A✓via shell pagesnpm run build

Environment Variables in Production

Set environment variables through your hosting platform's dashboard:

PlatformHow to Set
Node.jsUse .env file or system environment variables
NetlifySite settings → Environment variables
VercelProject settings → Environment Variables
Cloudflarewrangler.toml or dashboard
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.
Was this helpful?