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.
| Platform | Command | Notes |
|---|---|---|
| Node.js | npm run deploy | Default - uses the production server |
| Static Export | npm run build | GitHub Pages, S3, Firebase, Surge |
| Netlify | npm run deploy | Automated by the deploy tool |
| Vercel | npm run deploy | Automated by the deploy tool |
| Cloudflare | npm run deploy | Automated by the deploy tool |
| Deno Deploy | npm run deploy | Automated by the deploy tool |
npm run deploy works for Node.js, Netlify, Vercel, Cloudflare, and Deno Deploy. Static export uses npm run build which pre-renders all routes.The deploy tool makes deployment effortless. Simply run:
When you run npm run deploy, it will:
It asks which platform you want to deploy to. Choose Web for any hosting provider:
If you picked Web, it then asks for the hosting provider. Each section below explains what the deploy tool generates for that target.
It needs to know where to push the project. Enter your repository URL (skipped when an origin remote already exists):
By default it pushes to the remote's default branch, falling back to main. You can pick an existing branch or create a new one:
A confirmation prompt appears before generating files and pushing:
Finally, it asks for a commit message. Press Enter to use the default:
vite.config.ts needed. Learn more at bini-deploy.The default deployment option. Bini.js ships with a zero-dependency production server.
Your app will be served at the port specified by PORT (default: 3000):
npm run build and start to npm run startpm2 to keep the server runningWhen you choose Netlify in the hosting prompt, the deploy tool automatically generates:
netlify.toml - Build and function configurationnetlify/functions/api.mjs - API route handlernetlify/edge-functions/spa-fallback.ts - only without pre-renderingnodemailer, fs, or path may not work. Use Web API alternatives.When you choose Vercel in the hosting prompt, the deploy tool automatically generates:
vercel.json - Routing and build configurationapi/index.ts - Serverless function entry pointapi/tsconfig.json - only for TypeScript projects with API routesWhen you choose Cloudflare Workers in the hosting prompt, the deploy tool automatically generates:
wrangler.toml - Worker configurationworker.ts - Worker entry point with API routespublic/.assetsignore - excludes the API bundle from static assetsWhen you choose Deno Deploy in the hosting prompt, the deploy tool automatically generates:
server/index.ts - Deno Deploy entry pointFor 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.
The pre-rendered files will be in the dist/ folder. Suitable for:
Set the base option in vite.config.ts if deploying to a subpath:
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 | API Runtime | Static | Dynamic | Command |
|---|---|---|---|---|
| Node.js | Node.js | ✓ | ✓ | npm run deploy |
| Netlify | Node.js Functions | ✓ | ✓ | npm run deploy |
| Vercel | Node.js Runtime | ✓ | ✓ | npm run deploy |
| Cloudflare | Workers | ✓ | ✓ | npm run deploy |
| Deno Deploy | Deno | ✓ | ✓ | npm run deploy |
| Static Export | N/A | ✓ | via shell pages | npm run build |
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.npm run build and npm run preview before deploying.Run the production server for Node.js hosting with ETag caching and graceful shutdown.
Pre-render every route to static HTML for GitHub Pages, S3, or any static host.
Deploy to Vercel, Netlify, Cloudflare Workers, Deno Deploy, or Node.js.
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.
| Platform | Command | Notes |
|---|---|---|
| Node.js | npm run deploy | Default - uses the production server |
| Static Export | npm run build | GitHub Pages, S3, Firebase, Surge |
| Netlify | npm run deploy | Automated by the deploy tool |
| Vercel | npm run deploy | Automated by the deploy tool |
| Cloudflare | npm run deploy | Automated by the deploy tool |
| Deno Deploy | npm run deploy | Automated by the deploy tool |
npm run deploy works for Node.js, Netlify, Vercel, Cloudflare, and Deno Deploy. Static export uses npm run build which pre-renders all routes.The deploy tool makes deployment effortless. Simply run:
When you run npm run deploy, it will:
It asks which platform you want to deploy to. Choose Web for any hosting provider:
If you picked Web, it then asks for the hosting provider. Each section below explains what the deploy tool generates for that target.
It needs to know where to push the project. Enter your repository URL (skipped when an origin remote already exists):
By default it pushes to the remote's default branch, falling back to main. You can pick an existing branch or create a new one:
A confirmation prompt appears before generating files and pushing:
Finally, it asks for a commit message. Press Enter to use the default:
vite.config.ts needed. Learn more at bini-deploy.The default deployment option. Bini.js ships with a zero-dependency production server.
Your app will be served at the port specified by PORT (default: 3000):
npm run build and start to npm run startpm2 to keep the server runningWhen you choose Netlify in the hosting prompt, the deploy tool automatically generates:
netlify.toml - Build and function configurationnetlify/functions/api.mjs - API route handlernetlify/edge-functions/spa-fallback.ts - only without pre-renderingnodemailer, fs, or path may not work. Use Web API alternatives.When you choose Vercel in the hosting prompt, the deploy tool automatically generates:
vercel.json - Routing and build configurationapi/index.ts - Serverless function entry pointapi/tsconfig.json - only for TypeScript projects with API routesWhen you choose Cloudflare Workers in the hosting prompt, the deploy tool automatically generates:
wrangler.toml - Worker configurationworker.ts - Worker entry point with API routespublic/.assetsignore - excludes the API bundle from static assetsWhen you choose Deno Deploy in the hosting prompt, the deploy tool automatically generates:
server/index.ts - Deno Deploy entry pointFor 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.
The pre-rendered files will be in the dist/ folder. Suitable for:
Set the base option in vite.config.ts if deploying to a subpath:
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 | API Runtime | Static | Dynamic | Command |
|---|---|---|---|---|
| Node.js | Node.js | ✓ | ✓ | npm run deploy |
| Netlify | Node.js Functions | ✓ | ✓ | npm run deploy |
| Vercel | Node.js Runtime | ✓ | ✓ | npm run deploy |
| Cloudflare | Workers | ✓ | ✓ | npm run deploy |
| Deno Deploy | Deno | ✓ | ✓ | npm run deploy |
| Static Export | N/A | ✓ | via shell pages | npm run build |
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.npm run build and npm run preview before deploying.Run the production server for Node.js hosting with ETag caching and graceful shutdown.
Pre-render every route to static HTML for GitHub Pages, S3, or any static host.
Deploy to Vercel, Netlify, Cloudflare Workers, Deno Deploy, or Node.js.