Railway is an infrastructure platform with instant deployments from GitHub, automatic SSL, and built-in database provisioning. It auto-detects Bun projects and requires zero configuration for most apps. Prerequisites:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/oven-sh/bun/llms.txt
Use this file to discover all available pages before exploring further.
- A Bun application ready for deployment
- A Railway account
- A GitHub account (for dashboard deployments) or the Railway CLI
Method 1: Deploy via CLI
Add a database (optional)
If your app uses PostgreSQL, add it before deploying:
Skip this step if your application does not need a database.
Method 2: Deploy via Dashboard
Create a new project
- Go to the Railway Dashboard.
- Click + New → GitHub repo.
- Authorize Railway and select your repository.
Add a database (optional)
- In the project canvas, click + New → Database → Add PostgreSQL.
- Select your app service (not the database).
- Go to the Variables tab.
- Click + New Variable → Add Reference and select
DATABASE_URLfrom the Postgres service.
Skip this step if your application does not need a database.
Configuration
By default, Railway uses Nixpacks to auto-detect and build your Bun project with zero configuration. For better Bun support and guaranteed compatibility with the latest Bun versions, use Railpack instead. Create arailway.json in your project root:
railway.json
Custom start command
To override the default start command, set it in the Railway dashboard under Settings → Deploy → Start command, or add it torailway.json:
railway.json
Environment variables
Set environment variables in the Railway dashboard under your service’s Variables tab. They are injected intoprocess.env at runtime: