Export your Lovable project code via GitHub sync or ZIP download through Dev Mode. Connect GitHub first (Settings > Connectors > GitHub), then clone the repo and deploy to any hosting platform. For a quick export without GitHub, open Dev Mode and download the project as a ZIP file. Set VITE_SUPABASE_URL, VITE_SUPABASE_PUBLISHABLE_KEY, and VITE_SUPABASE_PROJECT_ID as environment variables on your hosting platform.
Why exporting Lovable code requires specific adjustments for external hosting
Lovable projects are standard Vite + React + TypeScript applications, which means they can run on any hosting platform that supports static sites. However, Lovable manages some things behind the scenes that you need to configure manually when deploying elsewhere. The biggest adjustment is environment variables. Lovable stores secrets in its Cloud tab, and these are automatically injected during builds on lovable.app. When you deploy to Vercel, Netlify, or another platform, you need to set these variables manually. Without them, your app cannot connect to Supabase and will fail silently or show connection errors. SPA routing is another common issue. Lovable apps use React Router with BrowserRouter for client-side routing. On lovable.app, this works automatically. On other platforms, you need to configure a fallback rule so all URL paths serve index.html, letting React Router handle the routing. Without this, direct URL visits return 404 errors.
- Environment variables from Lovable Cloud are not automatically available on external hosting platforms
- SPA fallback routing is not configured on the target hosting platform
- The build output directory (dist/) is not correctly specified in the hosting platform's settings
- Internal @lovable packages referenced in the code may not be publicly available after export
- Node version mismatch — Lovable uses Node 22, which must be specified on the hosting platform
Error messages you might see
VITE_SUPABASE_URL is not definedThe app tries to connect to Supabase but the environment variable is not set on your hosting platform. Add VITE_SUPABASE_URL, VITE_SUPABASE_PUBLISHABLE_KEY, and VITE_SUPABASE_PROJECT_ID in your host's environment variable settings.
404 Not Found (on direct URL navigation)Your hosting platform does not have SPA fallback routing configured. Add a rewrite rule so all paths serve index.html. For Vercel: add vercel.json. For Netlify: add a _redirects file.
Module not found: @lovable/uiThe @lovable/ui package is internal to Lovable and may not be available in public npm. Replace @lovable imports with their shadcn/ui equivalents or install them from the correct registry.
Before you start
- A Lovable project you want to deploy outside of lovable.app
- A GitHub account (for GitHub sync method) or a Pro plan (for ZIP download via Dev Mode)
- An account on your target hosting platform (Vercel, Netlify, AWS, etc.)
How to fix it
Export your project code via GitHub sync
GitHub sync creates a two-way connection that keeps your code accessible and version-controlled
Export your project code via GitHub sync
GitHub sync creates a two-way connection that keeps your code accessible and version-controlled
Click the GitHub icon in the top-right corner of the Lovable editor, or go to Settings > Connectors > GitHub. Connect your GitHub account if you have not already. Choose the organization or personal account, then click Transfer anyway to create a new repository. Lovable pushes your entire project code to the new repo. This repo includes all source files, package.json, vite.config.ts, and the project structure. You can now clone this repo and deploy from it.
// Project only exists inside Lovable editor// No external access to the code// After GitHub sync:// github.com/your-org/your-project// src/// public/// package.json// vite.config.ts// index.html// .env.exampleExpected result: Your project code is now in a GitHub repository. Every future change in Lovable syncs to GitHub automatically.
Alternatively, download as ZIP via Dev Mode
ZIP download gives you a one-time export without needing a GitHub account
Alternatively, download as ZIP via Dev Mode
ZIP download gives you a one-time export without needing a GitHub account
If you prefer not to use GitHub, open Dev Mode by clicking the + button next to Preview and selecting Code. In the Dev Mode panel, look for the download option to download the full project as a ZIP file. Extract the ZIP on your computer. This gives you the complete project source code. Note that ZIP download is a snapshot — it does not sync future changes automatically like GitHub does.
// No way to get the code outside Lovable without GitHub// Download ZIP from Dev Mode:// 1. Click + next to Preview → Code// 2. Click the download icon to get the ZIP// 3. Extract on your computer// 4. Contains: src/, public/, package.json, etc.Expected result: A ZIP file containing your complete project source code, ready to deploy from your local machine.
Set environment variables on your hosting platform
Lovable Cloud secrets are not exported — you must set them manually on your hosting platform for the app to function
Set environment variables on your hosting platform
Lovable Cloud secrets are not exported — you must set them manually on your hosting platform for the app to function
Find your environment variables in Lovable: open the Cloud tab (click + next to Preview, then Cloud) and go to Secrets. Note the values for VITE_SUPABASE_URL, VITE_SUPABASE_PUBLISHABLE_KEY, and VITE_SUPABASE_PROJECT_ID. You can also find these in the .env file visible in Dev Mode. On your hosting platform (Vercel, Netlify, etc.), add these as environment variables in the project settings. Variables prefixed with VITE_ are embedded at build time.
// Secrets are stored in Lovable Cloud tab → Secrets// Not available on external platforms// On Vercel/Netlify, add these environment variables:// VITE_SUPABASE_URL = https://[project-id].supabase.co// VITE_SUPABASE_PUBLISHABLE_KEY = eyJhbG...// VITE_SUPABASE_PROJECT_ID = your-project-id//// Also add any custom secrets your app uses// (API keys for Stripe, etc.)Expected result: Your deployed app connects to Supabase correctly and all features that depend on environment variables work.
Configure SPA routing and build settings on your hosting platform
Without SPA fallback routing, direct URL navigation returns 404 errors on static hosting platforms
Configure SPA routing and build settings on your hosting platform
Without SPA fallback routing, direct URL navigation returns 404 errors on static hosting platforms
Configure your hosting platform with the correct build command (npm run build), output directory (dist), and Node version (22). Then add SPA fallback routing so all URL paths serve index.html. For Vercel, create a vercel.json file in your project root. For Netlify, create a _redirects file in the public/ folder. If your deployment involves complex configurations across multiple services, RapidDev's engineers have deployed 600+ Lovable projects to external hosts and can handle the setup.
// No SPA routing configured// Direct URL visits return 404// vercel.json (add to project root for Vercel){ "rewrites": [ { "source": "/(.*)", "destination": "/index.html" } ]}// public/_redirects (add for Netlify)/* /index.html 200// Build settings on hosting platform:// Build command: npm run build// Output directory: dist// Node version: 22Expected result: Your app deploys successfully. All routes work when accessed directly, and the build completes without errors.
Complete code example
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}Best practices to prevent this
- Use GitHub sync over ZIP download — it keeps your code version-controlled and enables automatic deployments on push
- Never hardcode API keys in source code — always use environment variables with the VITE_ prefix for frontend variables
- Set Node version to 22 on your hosting platform to match Lovable's build environment
- Add vercel.json or _redirects to your project before the first external deployment to avoid 404 errors
- Copy environment variables from Lovable's Cloud tab > Secrets to your hosting platform's environment settings
- Test the deployed version in an incognito window to catch any caching or environment variable issues
- If your project uses Lovable Cloud (managed Supabase), the backend stays on Lovable's infrastructure even if frontend hosting moves
- After export, check that all @lovable/* package imports resolve correctly or replace them with public alternatives
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I exported my Lovable project to GitHub and want to deploy it to [Vercel/Netlify/other]. My project uses Supabase for the backend. Here is my project structure: [paste your file tree here] Please: 1. Tell me which environment variables I need to set on the hosting platform 2. Create a vercel.json (or _redirects for Netlify) for SPA routing 3. List the build settings I need to configure 4. Check if there are any @lovable packages that need to be replaced 5. Tell me if I need to update any OAuth redirect URLs
I am deploying this project to Vercel. Please add a vercel.json file to the project root with SPA rewrite rules so all routes serve index.html. Also add cache headers for static assets in the /assets/ directory. Make sure the .env.example file lists all required environment variables with placeholder values and comments explaining each one.
Frequently asked questions
How do I export my Lovable project code?
Two methods: (1) Connect GitHub via Settings > Connectors > GitHub — this creates a synced repo. (2) Open Dev Mode (+ button > Code) and download the project as a ZIP file. GitHub sync is recommended because it stays in sync with future changes.
Can I deploy a Lovable project to any hosting platform?
Yes. Lovable projects are standard Vite + React apps that build to static files in the dist/ folder. They work on Vercel, Netlify, AWS Amplify, Cloudflare Pages, or any platform that serves static sites. Set the build command to npm run build and output directory to dist.
Do I need to move my Supabase backend when deploying elsewhere?
No. Lovable's architecture separates the frontend from the backend. Your frontend can be hosted anywhere while the Supabase backend stays on Lovable Cloud (or your own Supabase instance). Just set the VITE_SUPABASE_URL environment variable to point to the correct Supabase instance.
Why do I get 404 errors on my externally deployed Lovable app?
Lovable apps use client-side routing (React Router). When you visit a URL directly, the hosting platform looks for a file at that path, which does not exist. Add an SPA fallback rule that serves index.html for all paths so React Router can handle the routing.
What environment variables do I need for external deployment?
At minimum: VITE_SUPABASE_URL, VITE_SUPABASE_PUBLISHABLE_KEY, and VITE_SUPABASE_PROJECT_ID. Plus any custom API keys your app uses (Stripe, etc.). Find these values in Lovable's Cloud tab > Secrets or in the .env file in Dev Mode.
What if I can't fix this myself?
If your deployment involves custom build configurations, CI/CD pipelines, or multiple environments (staging and production), RapidDev's engineers can set up the entire deployment pipeline. They have deployed 600+ Lovable projects to Vercel, Netlify, and custom hosting.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your issue.
Book a free consultation