Deploy Bun + Elysia + React (Monorepo)
Deploy and host a Bun monorepo with Elysia and React
Just deployed
Just deployed
Deploy and Host Bun + Elysia + React (Monorepo) on Railway
A production-ready monorepo combining Bun's fast runtime with Elysia's type-safe API framework and React + Vite for the frontend. Features end-to-end type safety via Eden Treaty, shared type contracts, and native binary compilation for optimal performance.
About Hosting Bun + Elysia + React (Monorepo)
Deploying a monorepo requires coordinating multiple services that share code and types. This template deploys the API and UI as independent Railway services with a shared contracts package for type-safe communication. The API compiles to a native binary for optimal cold start performance, while private networking enables secure service-to-service calls. Railway's variable references (${{service.VARIABLE}}) connect services automatically, and watch paths ensure rebuilds when shared code changes. Each service scales independently while maintaining a single source of truth for types.
Common Use Cases
- Full-stack applications with type-safe API calls between frontend and backend
- Microservices that share types across multiple services
- Rapid prototyping with hot reload on both frontend and backend
- Production deployments with optimized native binary compilation
Dependencies for Bun + Elysia + React (Monorepo) Hosting
- Bun >= 1.3.5 - JavaScript runtime, package manager, and bundler
- Elysia - Type-safe HTTP framework with automatic route inference
- React + Vite - Frontend with instant HMR
- @elysiajs/eden - Type-safe API client for end-to-end safety
Deployment Dependencies
Implementation Details
Project Structure
bun-monorepo-railway/
├── apps/
│ ├── api/ # Elysia backend server
│ └── ui/ # React + Vite frontend
├── packages/
│ └── contracts/ # Shared type definitions
└── package.json # Root workspace configuration
For more information, checkout the Github repo
Service Configuration
| Service | Root Directory | Build Command | Start Command |
|---|---|---|---|
| API | apps/api | bun --filter @bun-monorepo-railway/api build | ./apps/api/dist/server |
| UI | apps/ui | bun --filter @bun-monorepo-railway/ui build | - |
Environment Variables
| Service | Variable | Description |
|---|---|---|
| API | FRONTEND_URL | Frontend origin for CORS. Use ${{Frontend.RAILWAY_PUBLIC_DOMAIN}} |
| UI | VITE_API_URL | API base URL. Use https://${{Backend.RAILWAY_PUBLIC_DOMAIN}} |
| UI | RAILPACK_SPA_OUTPUT_DIR | Directory containing built static files. Use apps/ui/dist |
Why Deploy Bun + Elysia + React (Monorepo) on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Bun + Elysia + React (Monorepo) on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content