Migrate a Lovable app off Lovable hosting without breaking auth or the database
By AI App Medic · Updated · Lovable · Vercel · Netlify · Migration
People leave Lovable hosting for a few concrete reasons: they want their own deploy pipeline, they need a feature the built-in host does not offer, or a company rule says where the site must run. You can keep building in Lovable and serve production somewhere else. You do not have to move the database on the same day, and you should not point your custom domain at the new host until a temporary URL already works.
Lovable's own guide to external hosting is the source of truth for stack-specific flags. The path below is the short version that avoids the usual outages: 404 on refresh, blank pages from missing env values, and login that still sends people to .lovable.app.
Step 1: get the source and see which stack you have
Connect the project to GitHub, GitLab, or Bitbucket with Lovable's Git sync if you can. That is the right mode for an ongoing deploy, because Lovable keeps sending changes to the repo. A zip download is a snapshot and is easier to fall behind. In the repo, open package.json:
- If you see
@tanstack/react-start, this is a TanStack Start app (Lovable's newer default). It has a server. A host that only serves static files will break server functions and server-rendered routes. Vercel, Netlify, and Cloudflare Pages can run it when the build uses the matching Nitro preset (often detected automatically). Node 22 is the version Lovable currently documents. - If you do not see that package, you likely have an older React + Vite SPA.
npm run buildwrites static files todist/. Any static host will do, as long as you add a fallback toindex.html(see 404 on refresh).
Clone the repo, install dependencies, and run the production build on your machine before you involve a host. That tells you the Node version, the env names, and whether the project already compiles.
Step 2: deploy to a temporary URL
Import the repo into Vercel, Netlify, or Cloudflare Pages. Use npm run build, Node 22, and for Vite/Netlify/Cloudflare set the publish directory to dist. Vercel usually detects the framework itself.
Copy environment variables from the project's .env in Lovable, and set them on the new host before the production build. Typical browser names:
VITE_SUPABASE_URL
VITE_SUPABASE_PUBLISHABLE_KEY
# some projects still use VITE_SUPABASE_ANON_KEY
# plus VITE_SUPABASE_PROJECT_ID when the template needs it
TanStack Start apps also need the same values without the VITE_ prefix for server code (SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY, and any function secrets). Client values are baked in at build time, so a change means a new deploy. The failure mode looks like the one in Bolt apps on Netlify with missing env values.
Do not put a service-role key or payment secret in a VITE_ name. Keep those on the server only.
Step 3: verify before you touch DNS
On the *.vercel.app or *.netlify.app URL, walk through this list and fix each miss before you move the domain:
- Open a nested route and refresh. A 404 on a Vite app is a missing SPA fallback. A 404 or a dead server function on a TanStack app usually means the host is not running the server output.
- Sign in, sign out, and repeat a password reset. Add the new origin to Supabase Site URL and Redirect URLs, and to Google or GitHub if you use them. Details are in auth redirects.
- Create, read, and update a record. Upload a file if you use Storage.
- On TanStack Start, also hit a server-rendered page and one server function, not only the client UI.
Lovable's Publish button will still publish to Lovable hosting. That is useful: leave the current custom domain on Lovable until the new URL is proven. If Git sync is connected, every Lovable change can also trigger a deploy on the new host, following the branch rules you set there.
Step 4: point the domain, then decide about the backend
When the temporary URL is solid, follow the new host's custom-domain instructions and issue its certificate. Remove or replace the records that pointed at Lovable, without deleting MX records for your email. The .lovable.app address will keep serving the last published Lovable version until you unpublish. Do not unpublish or delete the Lovable project in the same hour you switch DNS.
You can stop here, with the UI on Vercel or Netlify and the data still on the built-in backend or your current Supabase project. Move the backend only if you need the database in your own account or region. That path is longer: create a new Supabase project, apply migrations in order, restore data carefully, reconfigure auth providers, copy storage files, set function secrets, deploy Edge Functions, and only then point a test build at the new project. Lovable documents that sequence in detail. Do not try to "just change the keys" in production on the same afternoon you move hosting.
When you are fully gone
Search the code for the old backend URL, app connectors, and AI calls that still go through Lovable. Those keep using your Lovable workspace until you replace them. Download a database export and storage files before you remove Cloud or delete the project. A code export or a DNS change does not cancel a Lovable subscription by itself; you turn that off separately when you are ready.
If you are only trying to get a custom domain working on Lovable, you may not need this migration at all. Start with Lovable custom domain not working.
FAQ
Does moving the frontend also move my database?
No. You can serve the UI from Vercel or Netlify and keep using Lovable's built-in backend or your existing Supabase project. Moving data is a separate, careful process.
Will the Publish button in Lovable deploy to Vercel?
No. Publish still updates Lovable hosting. If Git sync is on, a push can trigger the new host. The two pipelines are independent, which is useful while you test.
Can I go back?
Yes, as long as you have not deleted the Lovable project or the database. The .lovable.app URL keeps serving the last version you published there until you unpublish.
Related guides
- Lovable custom domain not working: fix DNS, SSL, and the sign-in redirect
- Bolt.new works in preview but breaks on Netlify: missing environment variables
- Lovable or Bolt app returns 404 on refresh: the SPA fallback for every host
- Supabase login redirects to localhost (or the preview URL) after deploy: how to fix it
- TypeError: Failed to fetch dynamically imported module, after a Vite deploy