-
Install Railway CLI (optional but recommended):
npm i -g @railway/cli
-
Login to Railway:
railway login
-
Initialize Railway project:
railway init
-
Deploy:
railway up
- Go to railway.app
- Click "New Project"
- Select "Deploy from GitHub repo"
- Connect your repository
- Railway will automatically detect the monorepo structure
Railway will:
- Run
npm installat the root (installs all workspace dependencies) - Run
npm run build(builds all packages: shared → frontend → backend) - Run
npm start(starts the backend server)
Railway automatically provides:
PORT- Railway sets this automatically (backend usesprocess.env.PORT || 3001)
Optional environment variables you can set:
NODE_ENV=production
The build process automatically handles dependencies:
- shared package builds first (required by backend)
- frontend builds (static export to
frontend/out) - backend builds (TypeScript compilation)
After deployment:
- Frontend:
https://your-app.railway.app/web - API:
https://your-app.railway.app/api - Health Check:
https://your-app.railway.app/api/health
If build fails:
- Check Railway logs:
railway logs - Ensure all dependencies are in
package.json(not just devDependencies) - Verify Node.js version (Railway uses Node 18+ by default)