Prerequisites:
- A Bun application ready for deployment
- A Railway account
- Railway CLI (for CLI deployment method)
- A GitHub account (for Dashboard deployment method)
Method 1: Deploy via CLI
Step 4
After initializing the project, add a new database and service.
Step 4 is only necessary if your application uses a database. If you don’t need PostgreSQL, skip to Step 5.
terminal
Method 2: Deploy via Dashboard
Step 1
Create a new project
- Go to Railway Dashboard
- Click ”+ New” → “GitHub repo”
- Choose your repository
Step 2
Add a PostgreSQL database, and connect this database to the service
Step 2 is only necessary if your application uses a database. If you don’t need PostgreSQL, skip to Step 3.
- Click ”+ New” → “Database” → “Add PostgreSQL”
- After the database has been created, select your service (not the database)
- Go to “Variables” tab
- Click ”+ New Variable” → “Add Reference”
- Select
DATABASE_URLfrom postgres
Configuration (Optional)
By default, Railway uses Nixpacks to automatically detect and build your Bun application with zero configuration. However, using the Railpack application builder provides better Bun support, and will always support the latest version of Bun. The pre-configured templates use Railpack by default. To enable Railpack in a custom project, add the following to yourrailway.json:
railway.json