Hire Lovable Xperts
Migration

How to Migrate a Lovable Site to Netlify

Netlify is a reliable hosting choice for Lovable apps, especially those using form handling or needing a simple deploy pipeline. The migration follows the same pattern as Vercel and Cloudflare, with Netlify-specific steps: the publish directory, client-side routing redirects, and the environment-variable scoping that trips up many first-time deployers. This guide covers every step.

By Founder Name · Last verified: 2026-06-24

Before you start: prerequisites for a Netlify migration

Before you open the Netlify dashboard, inventory everything your Lovable app depends on — environment variables, the Supabase URL and keys, and any client-side routing redirects. A missing variable or skipped redirect causes a silent failure that looks unrelated to what actually went wrong, so work through this prerequisite checklist first.

  1. Confirm your Lovable preview is stable — never migrate a broken app.
  2. List every variable in Lovable Project Settings → Environment (all VITE_ prefixed keys).
  3. Confirm your GitHub repo exists and Lovable has pushed the latest code to it.
  4. Check your vite.config.ts for the build output directory — it should be dist for Vite projects.
  5. Decide whether you are using the same Supabase project (easiest) or a new one (requires extra steps).
  6. If your app uses client-side routing (React Router), note that Netlify needs a _redirects file — you will add it during setup.

How does Netlify compare to Vercel and Cloudflare for a Lovable app?

Netlify, Vercel, and Cloudflare Pages all support Vite and React projects with similar free tiers. The differences that matter for Lovable migrations are: how each host scopes environment variables, how client-side routing is handled, and what happens at build time with VITE_ prefixed variables.

Netlify vs Vercel vs Cloudflare Pages for a Lovable/Vite app
FeatureNetlifyVercelCloudflare Pages
Vite auto-detectYesYesYes (sometimes needs manual override)
Publish directorydist (must confirm)dist (auto-detected)dist (must confirm)
Client-side routing fixAdd _redirects fileAdd vercel.json rewritesAutomatic (Pages handles SPAs)
VITE_ env at build timeYes — Site Config → Env VarsYes — Project Settings → Env VarsYes — Pages Settings → Env Vars
Env var scopingAll deploys or deploy contextsPreview / Production / DevPreview / Production separately
Form handlingBuilt-in (Netlify Forms)Not built-inNot built-in
Free bandwidth100 GB/mo100 GB/moUnlimited
Instant rollbackYes (one click)Yes (one click)Re-deploy previous
Functions runtimeNode.js (Netlify Functions)Node.js (Vercel Functions)V8 isolates (Workers)

How do I push my Lovable project to GitHub before deploying to Netlify?

Netlify deploys from a GitHub, GitLab, or Bitbucket repository — not from a ZIP or local folder. The first step is connecting Lovable to GitHub so your project has a repo. Once the repo exists, Netlify can watch it and trigger a deploy on every new commit — including commits Lovable makes when you edit in the AI editor.

  1. In Lovable, open Project Settings → GitHub.
  2. Connect your GitHub account and create a new repository.
  3. Click Push to GitHub. Lovable commits your current code.
  4. Verify the repo appears at github.com/<your-username>/<repo-name>.

How do I create a new site in Netlify from my Lovable repo?

In the Netlify dashboard, use the Add new site flow to import your GitHub repository. Netlify will attempt to auto-detect the build command and publish directory. For Lovable's Vite-based apps, it usually detects correctly — but confirm before the first deploy because an incorrect publish directory causes a successful build that returns 404 on every page.

  1. Log in to app.netlify.com and click Add new site → Import an existing project.
  2. Select GitHub and authorise Netlify to access your repositories.
  3. Pick your Lovable repo and confirm the branch (usually main).
  4. Build command: npm run build. Publish directory: dist.
  5. Before clicking Deploy site, open Advanced → Add a variable for each env var.
  6. Click Deploy site.

Which environment variables must I copy from Lovable to Netlify?

Every VITE_ prefixed variable in Lovable's Project Settings → Environment must be added to Netlify Site Configuration → Environment Variables before the first deploy. The two you must not miss are VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY — without them the app builds but Supabase is unreachable and the app appears blank or throws uncaught errors.

Netlify does not transfer variables from Lovable automatically. Any missing VITE_ variable causes a blank page at runtime, not a build failure — making it hard to diagnose without checking the browser console.

How do I update Supabase to accept requests from my Netlify domain?

After your first successful Netlify deploy, you will have a *.netlify.app URL. Add it to Supabase Authentication → URL Configuration → Redirect URLs so auth callbacks succeed. If you skip this step, users who try to log in will get a silent failure or a CORS error even though the app loads fine.

  1. Copy your *.netlify.app URL from Netlify Site Configuration → General → Site information.
  2. Open Supabase → Authentication → URL Configuration.
  3. Add the *.netlify.app URL to Redirect URLs.
  4. After DNS cutover, add your custom domain too.

Common Netlify deploy errors and fixes

Netlify surfaces most errors in the deploy log, but some failures — especially env-var problems and Supabase auth issues — only appear at runtime in the browser console. The table below maps the most common symptoms to causes and fixes for Lovable apps migrating to Netlify.

Netlify deploy error → cause → fix
Error / SymptomMost likely causeFix
Blank page after successful buildVITE_ env vars missing at build timeAdd all VITE_ vars in Netlify → Site Configuration → Environment Variables, then trigger a new deploy
All routes return 404 on direct accessPublish directory wrong or missing _redirects file for SPA routingConfirm publish directory is dist; add public/_redirects with: /* /index.html 200
Auth callback fails / redirect loopSupabase Redirect URLs don't include *.netlify.appAdd *.netlify.app URL to Supabase → Authentication → URL Configuration → Redirect URLs
Env vars work in preview but not productionVariables scoped to deploy context incorrectlyIn Netlify → Site Configuration → Env Variables, set each var for All scopes or explicitly for Production
CORS error on Supabase requestsNew domain not in Supabase allowed originsAdd your Netlify domain to Supabase → Authentication → URL Configuration → Additional Redirect URLs
Netlify Forms not receiving submissionsForm not tagged with data-netlify attribute or not detected at build timeAdd data-netlify='true' to the <form> element and trigger a new deploy so Netlify detects it at build time
Build fails: Cannot resolve @/ importsPath alias not configured — missing vite.config.ts aliasAdd resolve.alias: { '@': path.resolve(__dirname, './src') } to vite.config.ts
Users cannot log in after DNS cutoverSupabase Site URL still points to Lovable or old domainUpdate Supabase → Authentication → URL Configuration → Site URL to your new custom domain

What common mistakes break a Lovable-to-Netlify migration?

The most common issues are: publish directory set to build instead of dist (404 on all pages); env vars added to preview context only (production deploys fail); Supabase origin not updated (auth 403); and Netlify's default redirect rules conflicting with Supabase auth callback parameters. Check Netlify deploy logs, the browser network tab, and the Supabase dashboard in that order.

If your Lovable app uses client-side routing (React Router, for example), add a _redirects file in the public folder with the content: /* /index.html 200 — otherwise Netlify returns 404 on direct URL access to nested routes.

How do I roll back if the Netlify migration breaks?

Netlify's Publish deploy button lets you promote any previous deployment in one click — without a new build. This is faster than reverting DNS and means you can fix env-var or publish-directory issues and re-deploy without touching your DNS records.

  1. In Netlify, go to your site → Deploys and find the last known-good build.
  2. Click on it → Publish deploy. Your Netlify URL immediately serves that build.
  3. If you need to restore the old host entirely, update your DNS CNAME back to Lovable's hostname in your DNS provider.
  4. The most common root causes to check: wrong publish directory (build vs dist) and env vars scoped to Deploy Preview instead of Production.

How do I handle Supabase auth password hashes when migrating to a new database?

If you are using a new Supabase project rather than the original one connected to Lovable, user passwords cannot be transferred because Supabase's GoTrue server does not export bcrypt hashes. Trigger a password-reset email to all users before you cut DNS. Let users know the reset is coming so they are not surprised when their old password stops working on the first day after migration.

Post-migration smoke test for Netlify

Run this checklist on your *.netlify.app URL before DNS cutover. Netlify has two failure modes that are specific to Lovable app migrations and easy to miss: the _redirects file required for client-side routing, and environment variables scoped to the wrong deploy context. Both cause silent failures that look unrelated to the actual cause.

  1. Navigate directly to a nested route (e.g., /dashboard/profile) — confirm it returns your React app and not a Netlify 404. If it 404s, the _redirects file is missing.
  2. Sign in and reload — confirm the Supabase session persists. If it does not, check Supabase Redirect URLs include your *.netlify.app URL.
  3. If your app uses Netlify Forms, submit a test entry and confirm it appears under the Netlify dashboard → Forms tab.
  4. Open Site Configuration → Environment Variables and verify each VITE_ variable is set for the Production deploy context, not just Deploy Preview.

Frequently asked questions

Does Netlify work well with Lovable's Vite build output?
Yes. Netlify detects Vite projects and sets the build command to npm run build and the publish directory to dist. If detection fails, set these manually. The only common issue is React Router apps needing a _redirects rule for client-side navigation.
Can I keep editing in Lovable after moving to Netlify?
Yes. If Lovable is connected to your GitHub repo, every edit in Lovable commits to GitHub, and Netlify's GitHub integration auto-deploys within seconds. You get the best of both: Lovable's AI editor for development and Netlify's infrastructure for production hosting.
Is Netlify free for a Lovable app?
Netlify's free tier includes 100 GB of bandwidth per month, 300 build minutes, and unlimited sites. Most Lovable apps stay well within these limits. The Pro plan adds team members, more build minutes, and higher bandwidth caps.
What if my app uses Supabase edge functions?
Supabase edge functions run on Supabase's own Deno runtime and are not affected by changing your front-end hosting. As long as env vars are set correctly and Supabase allowed origins include your new Netlify domain, edge functions work without any changes.
Why does my Netlify deploy return 404 on nested routes?
Netlify serves static files by default, so navigating directly to /dashboard/settings returns 404 because there is no file at that path. Add a _redirects file to your public folder with one line: /* /index.html 200. This tells Netlify to always serve index.html and let React Router handle routing.
How do I add environment variables to Netlify after the first deploy?
Go to your site in Netlify → Site Configuration → Environment Variables → Add a variable. After adding, trigger a new deploy (Deploys → Trigger deploy → Deploy site) so the new variables are baked into the next build. Netlify environment variables are set at build time for VITE_ prefixed vars, so a redeploy is required.
Can I use Netlify Forms with my Lovable app?
Yes. Add data-netlify='true' to any HTML form in your Lovable app, deploy to Netlify, and form submissions are automatically captured in the Netlify dashboard. Lovable's forms likely use JavaScript form handling — switch to standard HTML form attributes for Netlify Forms to detect them at build time.
How do I handle Stripe webhook updates after moving to Netlify?
After DNS cutover to your new domain on Netlify, update the webhook endpoint URL in your Stripe Dashboard under Developers → Webhooks. During the cutover window, run both the old Lovable-domain endpoint and the new Netlify endpoint in Stripe to avoid missing any events.
Why do my env vars work in Netlify's preview deploy but not in production?
Netlify lets you scope environment variables to specific deploy contexts: Production, Deploy Preview, and Branch Deploy. If you only set a variable for Deploy Preview, production builds run without it. Go to Site Configuration → Environment Variables and set each VITE_ variable for All scopes.
Does Netlify's free plan limit how many times I can redeploy during a migration?
Netlify's free tier includes 300 build minutes per month. A typical Lovable app builds in under 2 minutes, so 300 minutes covers roughly 150 deploys — more than enough for a migration with testing cycles. If you hit the limit, you can trigger a deploy from a cached build (no rebuild) which does not consume build minutes.

Talk to a senior engineer — not a salesperson.

Book a free 30-minute audit call. We'll diagnose what's wrong and tell you exactly what it costs to fix.

Book a free audit call