Skip to main content
RapidDev - Software Development Agency
lovable-issues

How to Deploy a Lovable Project to Vercel Without Errors

To deploy a Lovable project to Vercel: connect your GitHub repo to Vercel, set the build command to 'npm run build', the output directory to 'dist', and Node version to 22. Add a vercel.json file with an SPA rewrite rule so all routes serve index.html. Copy your VITE_SUPABASE_URL, VITE_SUPABASE_PUBLISHABLE_KEY, and VITE_SUPABASE_PROJECT_ID from Lovable's Cloud tab → Secrets to Vercel's environment variable settings. Each push to GitHub triggers automatic deployment.

Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate8 min read~15 minAll Lovable versions (Pro plan required for GitHub connection)March 2026RapidDev Engineering Team
TL;DR

To deploy a Lovable project to Vercel: connect your GitHub repo to Vercel, set the build command to 'npm run build', the output directory to 'dist', and Node version to 22. Add a vercel.json file with an SPA rewrite rule so all routes serve index.html. Copy your VITE_SUPABASE_URL, VITE_SUPABASE_PUBLISHABLE_KEY, and VITE_SUPABASE_PROJECT_ID from Lovable's Cloud tab → Secrets to Vercel's environment variable settings. Each push to GitHub triggers automatic deployment.

Why Vercel deployments fail without specific Lovable configuration

Lovable apps are standard Vite + React projects, which makes them fully compatible with Vercel. However, several configuration details must be set correctly or the deployment will fail or produce a broken site. The most common failure is missing environment variables. Lovable's Cloud tab Secrets do not automatically transfer to Vercel. If your app uses Supabase (as most Lovable apps do), the Supabase client throws an error on initialization, and the entire app fails to render — producing a blank white screen with no visible error. The second most common issue is SPA routing. Lovable apps use React Router with BrowserRouter for client-side routing. When a user navigates to /dashboard/settings and refreshes the page, Vercel tries to find a file at that path. Since there is no such file (it is all handled by React), Vercel returns a 404. The fix is a vercel.json rewrite rule that sends all requests to index.html. Vercel auto-detects build settings from package.json, but it sometimes picks the wrong framework or Node version. Lovable projects need Node 22, the build command npm run build, and the output directory dist/. If Vercel auto-detects a different configuration, the build fails.

  • Missing environment variables on Vercel — Lovable Secrets do not auto-transfer
  • No SPA rewrite rule — direct URL access returns 404 for all routes except /
  • Wrong Node version — Lovable projects require Node 22, Vercel may default to an older version
  • Output directory misconfigured — Vercel expecting build/ but Lovable uses dist/
  • GitHub repo not connected — Vercel needs repository access for automatic deployments
  • OAuth redirect URLs not updated for the new Vercel domain

Error messages you might see

Error: No Output Directory named "build" found after the Build completed

Vercel is looking for a 'build' folder but Lovable's Vite build outputs to 'dist'. Change the output directory in Vercel project settings to 'dist'.

404: NOT_FOUND — The page could not be found

You are accessing a route directly (like /dashboard) but Vercel has no file at that path. Add a vercel.json with an SPA rewrite rule that redirects all routes to /index.html.

Error: Command 'npm run build' exited with 1

The build failed on Vercel. Check the build logs for the specific error — common causes include TypeScript errors, missing dependencies, or wrong Node version. Set Node version to 22 in Vercel project settings.

supabaseUrl is required

The Supabase client cannot initialize because VITE_SUPABASE_URL is not set on Vercel. Add all VITE_ environment variables in Vercel's project settings under Environment Variables.

Before you start

  • A Lovable project connected to GitHub (Settings → Connectors → GitHub → Connect project)
  • A Vercel account at vercel.com (free tier works for most projects)
  • Your Supabase environment variables from Lovable's Cloud tab → Secrets
  • If using OAuth: access to your OAuth provider settings to update redirect URLs

How to fix it

1

Connect your GitHub repository to Vercel

Vercel deploys from GitHub — each push to the main branch triggers a new deployment

Go to vercel.com and sign in. Click Add New → Project. Vercel will show your GitHub repositories. Find the repository that Lovable created when you connected GitHub (it should have the same name as your Lovable project). Click Import. If you do not see it, click Adjust GitHub App Permissions to grant Vercel access to the correct repository or organization.

Expected result: Vercel shows the import configuration screen for your Lovable project repository.

2

Configure build settings for a Vite project

Vercel must use the correct build command, output directory, and Node version for Lovable projects

On the Vercel import screen, configure these settings before clicking Deploy. Framework Preset: select Vite (Vercel may auto-detect this). Build Command: npm run build. Output Directory: dist (not build). Then go to Settings → General and set Node.js Version to 22. If Vercel already deployed with wrong settings, update them in Settings → General and trigger a redeployment from the Deployments tab.

Expected result: Vercel build completes successfully and shows a deployment URL.

3

Add environment variables on Vercel

Lovable Cloud Secrets are not shared with Vercel — missing variables cause the app to crash on load

In your Vercel project, go to Settings → Environment Variables. Add each variable that your Lovable app needs. At minimum for Supabase projects: VITE_SUPABASE_URL (your Supabase project URL), VITE_SUPABASE_PUBLISHABLE_KEY (the anon/public key), and VITE_SUPABASE_PROJECT_ID. Find these values in Lovable's Cloud tab → Secrets, or in the .env file visible in Dev Mode. Set each variable for Production, Preview, and Development environments. After adding variables, trigger a redeployment.

Expected result: Your deployed app connects to Supabase successfully — no blank screens or API errors.

4

Add a vercel.json file for SPA routing

Without this rewrite rule, refreshing any page except the homepage returns a 404 error

Create a vercel.json file in your project root (next to package.json). This file tells Vercel to serve index.html for all routes, letting React Router handle the client-side routing. You can add this file via Dev Mode in Lovable, through GitHub, or by prompting Lovable: 'Create a vercel.json file in the project root with an SPA rewrite rule that redirects all routes to /index.html.'

Before
typescript
// No vercel.json — direct URL access to /dashboard returns 404
After
typescript
// vercel.json — SPA rewrite sends all routes to index.html
{
"rewrites": [
{ "source": "/(.*)", "destination": "/index.html" }
]
}

Expected result: All routes work correctly when accessed directly by URL or on page refresh. No more 404 errors.

5

Update OAuth redirect URLs for your Vercel domain

OAuth providers reject redirects to unregistered domains — login will fail on the new Vercel URL

If your app uses Google sign-in, GitHub OAuth, or another provider, you must add your new Vercel domain to the allowed redirect URLs. In your Supabase project settings, add the Vercel URL to the Redirect URLs list (for example https://your-app.vercel.app/**). Also update the Site URL to your Vercel domain. Then in your OAuth provider's console (Google Cloud Console, GitHub OAuth Apps), add the Vercel domain as an authorized redirect URI. If this involves coordinating OAuth configuration across multiple providers and domains, RapidDev's engineers have handled this exact deployment pipeline across 600+ Lovable projects.

Expected result: OAuth login works correctly on your Vercel domain — users can sign in and are redirected back to the app.

Complete code example

vercel.json
1{
2 "rewrites": [
3 {
4 "source": "/(.*)",
5 "destination": "/index.html"
6 }
7 ],
8 "headers": [
9 {
10 "source": "/assets/(.*)",
11 "headers": [
12 {
13 "key": "Cache-Control",
14 "value": "public, max-age=31536000, immutable"
15 }
16 ]
17 },
18 {
19 "source": "/(.*)",
20 "headers": [
21 {
22 "key": "X-Content-Type-Options",
23 "value": "nosniff"
24 },
25 {
26 "key": "X-Frame-Options",
27 "value": "DENY"
28 },
29 {
30 "key": "Referrer-Policy",
31 "value": "strict-origin-when-cross-origin"
32 }
33 ]
34 }
35 ]
36}

Best practices to prevent this

  • Always set Node.js version to 22 in Vercel project settings — Lovable projects use features that require Node 22
  • Add all VITE_ environment variables on Vercel before the first deployment to avoid blank-screen issues on launch
  • Use the vercel.json SPA rewrite rule from day one — add it when you first connect GitHub, not after users hit 404 errors
  • Set environment variables for all three Vercel environments (Production, Preview, Development) to avoid issues in preview deployments
  • Update OAuth redirect URLs immediately after deployment — do not wait until users report login failures
  • Enable automatic deployments only on the main branch to avoid hitting Vercel's 100/day deployment limit on active repos
  • Test the deployed app in an incognito window to ensure environment variables and authentication are working correctly

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I am deploying a Lovable (lovable.dev) project to Vercel. My project uses Vite + React + TypeScript + Supabase. Here is my current project setup: - package.json scripts: [paste the scripts section] - vite.config.ts: [paste the file] - Environment variables I use: [list them] - OAuth providers: [list any OAuth providers like Google, GitHub] Please: 1. Tell me the exact Vercel project settings (build command, output dir, Node version) 2. Create a vercel.json with SPA rewrite and security headers 3. List all environment variables I need to set on Vercel 4. Show me how to update OAuth redirect URLs for the new domain 5. Create a deployment checklist I can follow step by step

Lovable Prompt

Create a vercel.json file in the project root for deploying to Vercel. Add an SPA rewrite rule that sends all routes to /index.html so React Router works on direct URL access. Add cache headers for the /assets directory with a one-year max-age and immutable flag. Add security headers (X-Content-Type-Options: nosniff, X-Frame-Options: DENY, Referrer-Policy: strict-origin-when-cross-origin) for all routes. Do not modify any other files.

Frequently asked questions

How do I deploy a Lovable app to Vercel?

Connect your Lovable project to GitHub first (Settings → Connectors → GitHub). Then go to vercel.com, import the GitHub repository, set the build command to 'npm run build', output directory to 'dist', and Node version to 22. Add your VITE_ environment variables and click Deploy.

Why does my Lovable app show 404 on Vercel when refreshing a page?

Lovable apps use React Router for client-side routing. When you refresh a page like /dashboard, Vercel looks for a file at that path and finds nothing. Add a vercel.json file with a rewrite rule that sends all routes to /index.html so React Router handles the routing.

What environment variables do I need on Vercel for a Lovable project?

At minimum: VITE_SUPABASE_URL, VITE_SUPABASE_PUBLISHABLE_KEY, and VITE_SUPABASE_PROJECT_ID. Find these values in Lovable's Cloud tab → Secrets or in the .env file in Dev Mode. Add any other VITE_ variables your project uses for third-party APIs.

What Node version should I use for Lovable on Vercel?

Set Node.js version to 22 in your Vercel project settings (Settings → General → Node.js Version). Lovable projects use features and dependencies that require Node 22. Using an older version will cause build failures.

Does Lovable automatically deploy to Vercel when I make changes?

Yes, once connected. Every push to the main branch of your GitHub repository triggers a new Vercel deployment. Since Lovable syncs changes to GitHub automatically, making changes in Lovable and publishing will trigger a Vercel deployment after the GitHub sync completes.

Why is my Vercel build failing with exit code 1?

Check the Vercel build logs for the specific error. Common causes: TypeScript errors in your code, missing dependencies, wrong Node version (set to 22), or missing environment variables that cause the build script to fail. Fix the error in Lovable and push again.

What if I cannot deploy to Vercel myself?

Vercel deployment involves coordinating GitHub, environment variables, SPA routing, OAuth redirects, and custom domains. RapidDev's engineers have deployed 600+ Lovable projects to Vercel and can handle the entire deployment pipeline — from initial setup to custom domain configuration.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your issue.

Book a free consultation

Need help with your Lovable project?

Our experts have built 600+ apps and can solve your issue fast. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.