Deploy to Production in 5 Minutes

January 25, 2025 · Eden Stack Team

tutorialdeploymentvercelrailwayproduction

Deploy to Production in 5 Minutes

Eden Stack is designed for fast deployment. The web app goes to Vercel, the API goes to Railway, and the database is already on Neon. Let's get you live.

Prerequisites

Before you start:

  • Neon database created (you should have this from development)
  • GitHub repo with your code pushed
  • Vercel account (free tier works)
  • Railway account (free tier works)

Minute 0-2: Deploy the API to Railway

Step 1: Install Railway CLI

npm install -g @railway/cli
railway login

Step 2: Initialize and Deploy

cd apps/api
railway init
# Select "Create new project"
# Name it: my-app-api
 
railway up

Step 3: Set Environment Variables

railway variables set DATABASE_URL="your-neon-connection-string"
railway variables set BETTER_AUTH_SECRET="your-secret"
railway variables set BETTER_AUTH_URL="https://your-app-api.railway.app"
railway variables set NODE_ENV="production"
 
# Add any other secrets you need
railway variables set STRIPE_SECRET_KEY="sk_live_..."
railway variables set STRIPE_WEBHOOK_SECRET="whsec_..."
railway variables set RESEND_API_KEY="re_..."
railway variables set OPENAI_API_KEY="sk-..."

Step 4: Generate Domain

railway domain
# Copy the generated URL (e.g., my-app-api-production.railway.app)

Your API is now live! Test it:

curl https://my-app-api-production.railway.app/health
# Should return: {"status":"ok","timestamp":"..."}

Minute 2-4: Deploy the Web App to Vercel

Step 1: Import Project

  1. Go to vercel.com/new
  2. Import your GitHub repository
  3. Set the root directory to apps/web

Step 2: Configure Environment Variables

Add these in Vercel's dashboard:

VariableValue
VITE_API_URLhttps://my-app-api-production.railway.app
BETTER_AUTH_URLhttps://my-app.vercel.app

Step 3: Deploy

Click Deploy. Vercel will build and deploy automatically.

Your web app is now live at https://my-app.vercel.app!

Minute 4-5: Connect the Pieces

Update CORS on Railway

Your API needs to accept requests from your Vercel domain:

railway variables set CORS_ORIGIN="https://my-app.vercel.app"
railway up  # Redeploy with new config

Update Auth URLs

If using OAuth (Google, etc.), update callback URLs in your provider's dashboard:

ProviderCallback URL
Googlehttps://my-app-api-production.railway.app/api/auth/callback/google

Verify Everything Works

  1. Visit your Vercel URL
  2. Try logging in
  3. Create some data
  4. Check Railway logs for any errors
railway logs

Quick Reference: All Commands

# Deploy API
cd apps/api
railway up
 
# Deploy Web (push to main branch triggers Vercel)
git push origin main
 
# View logs
railway logs
 
# Check status
railway status

Environment Variables Checklist

Railway (API)

VariableRequiredNotes
DATABASE_URLYesNeon connection string
BETTER_AUTH_SECRETYes32+ char random string
BETTER_AUTH_URLYesYour Railway URL
NODE_ENVYesSet to production
CORS_ORIGINYesYour Vercel URL
STRIPE_SECRET_KEYIf using paymentsLive key
STRIPE_WEBHOOK_SECRETIf using paymentsWebhook secret
RESEND_API_KEYIf using email
INNGEST_EVENT_KEYIf using background jobs
OPENAI_API_KEYIf using AI
ANTHROPIC_API_KEYIf using agents

Vercel (Web)

VariableRequiredNotes
VITE_API_URLYesYour Railway URL
BETTER_AUTH_URLYesYour Vercel URL

Troubleshooting

CORS Errors

If you see CORS errors in the browser console:

  1. Verify CORS_ORIGIN is set correctly on Railway
  2. Ensure the URL doesn't have a trailing slash
  3. Redeploy: railway up

Auth Not Working

  1. Check BETTER_AUTH_URL matches your actual URL (no trailing slash)
  2. Verify BETTER_AUTH_SECRET is the same in both environments
  3. Check Railway logs for auth errors

Database Connection Errors

  1. Verify DATABASE_URL is correct
  2. Ensure it ends with ?sslmode=require
  3. Check if Neon project is active (not suspended)

Build Failures

# Check build logs
railway logs --build
 
# Or on Vercel, check the deployment logs in the dashboard

Automatic Deployments

Railway

Railway auto-deploys when you push to your connected branch:

# In apps/api
railway link
# Connect to your project
 
# Now every push deploys automatically
git push origin main

Vercel

Vercel deploys automatically on push by default. To disable:

  1. Go to Project Settings → Git
  2. Toggle off "Auto Deploy"

Cost Estimate

For a small-to-medium app:

ServiceFree TierPaid Estimate
Neon0.5 GB storage, 190 compute hours$19/mo for Pro
Railway$5 credit/month~$5-20/mo
Vercel100 GB bandwidth~$0-20/mo
Total$0-5/mo~$25-60/mo

Custom Domain

Vercel

  1. Go to Project Settings → Domains
  2. Add your domain
  3. Update DNS as instructed

Railway

railway domain --set yourdomain.com

Then add the CNAME record to your DNS.

Next Steps

  • Set up monitoring with Sentry - see @eden/observability package
  • Add analytics with PostHog - see @eden/analytics package
  • Configure Stripe webhooks for production
  • Set up Inngest in production

Your app is live! Check out the Deploy to Vercel and Deploy API docs for more advanced configuration.

Ready to build with Eden Stack?

One-time payment. Full source code. No lock-in.

View pricing