LovableRailwayBeginner7 min read

How to Deploy Your Lovable App to Railway

Deploy your Lovable-generated app to Railway for custom domains, environment variables, and a production-grade backend.

Before you start

  • A Lovable app connected to GitHub
  • A Railway account (free tier available)

Step by step

1

Push your Lovable app to GitHub

In Lovable, click the GitHub icon in the sidebar and connect your repository. This gives you a Git repo with all your code.

Paste this into Lovable:

Connect my app to GitHub so I can deploy it to Railway.
2

Create a new Railway project

Go to railway.app, click New Project → Deploy from GitHub Repo, and select your Lovable repository.

# On railway.app:
# New Project → Deploy from GitHub Repo
# Select your Lovable repo
3

Add environment variables

In Railway → Variables, add all the environment variables your app needs (Supabase URL, API keys, etc.).

VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key
4

Set the build command

Railway auto-detects most settings, but verify the build command is correct. For Vite apps (Lovable default), it should be npm run build.

# Railway → Settings → Build
# Build Command: npm run build
# Start Command: npm run preview
5

Add a custom domain

In Railway → Settings → Networking → Custom Domain, add your domain. Railway gives you the DNS records to add.

# Add CNAME record:
# Name: @ (or www)
# Value: your-app.up.railway.app
6

Enable automatic deploys

Railway automatically deploys every time you push to your main branch. Since Lovable pushes to GitHub, every change you make in Lovable auto-deploys.

Paste this into Lovable:

Make sure all future changes auto-deploy by keeping the GitHub connection active.
Deploy for free on Railway →

Common errors

Build fails with 'vite not found'

Railway can't find the Vite build tool.

Fix: Make sure vite is in your package.json dependencies, not just devDependencies. Run: npm install vite

Blank page after deploy

The app builds but shows nothing because static files aren't being served.

Fix: Set the start command to 'npx serve dist' or 'npm run preview' for Vite apps.

Environment variables not loading

Vite requires env vars to start with VITE_ to be accessible in the browser.

Fix: Rename variables to start with VITE_ (e.g., VITE_SUPABASE_URL).

Related guides

Weekly Newsletter

Get next week's fix before you need it.

Join developers getting weekly vibe coding tips, error fixes, and tool updates.

Subscribe on Substack →