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
| Platform | Command | Notes |
|---|---|---|
| Node.js | npm run deploy | Default - uses bini-server |
| Static Export | npm run build | GitHub Pages, S3, Firebase, Surge |
| Netlify | npm run deploy | Automated by bini-deploy |
| Vercel | npm run deploy | Automated by bini-deploy |
| Cloudflare | npm run deploy | Automated by bini-deploy |
| Deno Deploy | npm run deploy | Automated by bini-deploy |
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:
Step 1 - Choose the target platform
bini-deploy asks which platform you want to deploy to. Choose Web for any hosting provider:
? Select your target platform:> WebWindowsmacOSiOSLinuxAndroid↑↓ 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:
? Select hosting provider:> Node.js (default - bini-server)NetlifyVercelCloudflare WorkersDeno Deploy↑↓ navigate • ⏎ select
- Prompt you to choose your target platform: Web, Windows, macOS, Linux, Android, or iOS
- If you choose Web, it prompts for hosting provider: Node.js (default), Netlify, Vercel, Cloudflare, or Deno Deploy
- Automatically generates the platform-specific configuration files and entry points
- 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.tomland edge function entry - Vercel - Automatically generates
vercel.jsonand serverless function entry - Cloudflare - Automatically generates
wrangler.tomland worker entry - Deno Deploy - Automatically generates
server/index.tsentry
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.
$ npm run deploy
Your app will be served at the port specified by PORT (default: 3000):
# .env
PORT=3000Step 1 - Choose the target platform
bini-deploy asks which platform you want to deploy to. Choose Web for any hosting provider:
? Select your target platform:> WebWindowsmacOSiOSLinuxAndroid↑↓ 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:
? Select hosting provider:> Node.js (default - bini-server)NetlifyVercelCloudflare WorkersDeno Deploy↑↓ navigate • ⏎ select
Platforms
- Railway - Auto-detects Node.js, just connect your repo
- Render - Set build command to
npm run deployand start tonpm start - Fly.io - Use the Node.js builder
- VPS - Use
pm2to keep the server running
Netlify
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 configurationnetlify/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:
? Select your target platform:> WebWindowsmacOSiOSLinuxAndroid↑↓ 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:
? Select hosting provider:Node.js (default - bini-server)> NetlifyVercelCloudflare WorkersDeno Deploy↑↓ navigate • ⏎ select
nodemailer, fs, or path will not work. Use Web API alternatives.Vercel
Deploying to Vercel is completely automated with bini-deploy. No configuration needed.
$ npm run deploy
bini-deploy automatically generates:
vercel.json- Routing and build configurationapi/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:
? Select your target platform:> WebWindowsmacOSiOSLinuxAndroid↑↓ 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:
? Select hosting provider:Node.js (default - bini-server)Netlify> VercelCloudflare WorkersDeno Deploy↑↓ navigate • ⏎ select
Cloudflare Workers
Deploying to Cloudflare Workers is completely automated with bini-deploy. No configuration needed.
$ npm run deploy
bini-deploy automatically generates:
wrangler.toml- Worker configurationworker.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:
? Select your target platform:> WebWindowsmacOSiOSLinuxAndroid↑↓ 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:
? Select hosting provider:Node.js (default - bini-server)NetlifyVercel> Cloudflare WorkersDeno Deploy↑↓ navigate • ⏎ select
Deno 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
Step 1 - Choose the target platform
bini-deploy asks which platform you want to deploy to. Choose Web for any hosting provider:
? Select your target platform:> WebWindowsmacOSiOSLinuxAndroid↑↓ 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:
? Select hosting provider:Node.js (default - bini-server)NetlifyVercelCloudflare 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.
$ 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:
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.
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
| Platform | API Runtime | Static | Dynamic | Command |
|---|---|---|---|---|
| Node.js | Node.js | ✓ | ✓ | npm run deploy |
| Netlify | Deno (Edge) | ✓ | ✓ | npm run deploy |
| Vercel | Edge | ✓ | ✓ | npm run deploy |
| Cloudflare | Workers | ✓ | ✓ | npm run deploy |
| Deno Deploy | Deno | ✓ | ✓ | npm run deploy |
| Static Export | N/A | ✓ | via shell pages | npm run build |
Environment Variables in Production
Set environment variables through your hosting platform's dashboard:
| Platform | How to Set |
|---|---|
| Node.js | Use .env file or system environment variables |
| Netlify | Site settings → Environment variables |
| Vercel | Project settings → Environment Variables |
| Cloudflare | wrangler.toml or dashboard |
| Deno Deploy | Project settings → Environment Variables |
.env files with secrets to your repository. Use platform environment variables for production.Best Practices
- Test builds locally - Run
npm run buildandnpm run previewbefore 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.