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.
- Confirm your Lovable preview is stable — never migrate a broken app.
- List every variable in Lovable Project Settings → Environment (all VITE_ prefixed keys).
- Confirm your GitHub repo exists and Lovable has pushed the latest code to it.
- Check your vite.config.ts for the build output directory — it should be dist for Vite projects.
- Decide whether you are using the same Supabase project (easiest) or a new one (requires extra steps).
- 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.
| Feature | Netlify | Vercel | Cloudflare Pages |
|---|---|---|---|
| Vite auto-detect | Yes | Yes | Yes (sometimes needs manual override) |
| Publish directory | dist (must confirm) | dist (auto-detected) | dist (must confirm) |
| Client-side routing fix | Add _redirects file | Add vercel.json rewrites | Automatic (Pages handles SPAs) |
| VITE_ env at build time | Yes — Site Config → Env Vars | Yes — Project Settings → Env Vars | Yes — Pages Settings → Env Vars |
| Env var scoping | All deploys or deploy contexts | Preview / Production / Dev | Preview / Production separately |
| Form handling | Built-in (Netlify Forms) | Not built-in | Not built-in |
| Free bandwidth | 100 GB/mo | 100 GB/mo | Unlimited |
| Instant rollback | Yes (one click) | Yes (one click) | Re-deploy previous |
| Functions runtime | Node.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.
- In Lovable, open Project Settings → GitHub.
- Connect your GitHub account and create a new repository.
- Click Push to GitHub. Lovable commits your current code.
- 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.
- Log in to app.netlify.com and click Add new site → Import an existing project.
- Select GitHub and authorise Netlify to access your repositories.
- Pick your Lovable repo and confirm the branch (usually main).
- Build command: npm run build. Publish directory: dist.
- Before clicking Deploy site, open Advanced → Add a variable for each env var.
- 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.
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.
- Copy your *.netlify.app URL from Netlify Site Configuration → General → Site information.
- Open Supabase → Authentication → URL Configuration.
- Add the *.netlify.app URL to Redirect URLs.
- 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.
| Error / Symptom | Most likely cause | Fix |
|---|---|---|
| Blank page after successful build | VITE_ env vars missing at build time | Add all VITE_ vars in Netlify → Site Configuration → Environment Variables, then trigger a new deploy |
| All routes return 404 on direct access | Publish directory wrong or missing _redirects file for SPA routing | Confirm publish directory is dist; add public/_redirects with: /* /index.html 200 |
| Auth callback fails / redirect loop | Supabase Redirect URLs don't include *.netlify.app | Add *.netlify.app URL to Supabase → Authentication → URL Configuration → Redirect URLs |
| Env vars work in preview but not production | Variables scoped to deploy context incorrectly | In Netlify → Site Configuration → Env Variables, set each var for All scopes or explicitly for Production |
| CORS error on Supabase requests | New domain not in Supabase allowed origins | Add your Netlify domain to Supabase → Authentication → URL Configuration → Additional Redirect URLs |
| Netlify Forms not receiving submissions | Form not tagged with data-netlify attribute or not detected at build time | Add data-netlify='true' to the <form> element and trigger a new deploy so Netlify detects it at build time |
| Build fails: Cannot resolve @/ imports | Path alias not configured — missing vite.config.ts alias | Add resolve.alias: { '@': path.resolve(__dirname, './src') } to vite.config.ts |
| Users cannot log in after DNS cutover | Supabase Site URL still points to Lovable or old domain | Update 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.
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.
- In Netlify, go to your site → Deploys and find the last known-good build.
- Click on it → Publish deploy. Your Netlify URL immediately serves that build.
- If you need to restore the old host entirely, update your DNS CNAME back to Lovable's hostname in your DNS provider.
- 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.
- 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.
- Sign in and reload — confirm the Supabase session persists. If it does not, check Supabase Redirect URLs include your *.netlify.app URL.
- If your app uses Netlify Forms, submit a test entry and confirm it appears under the Netlify dashboard → Forms tab.
- 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?
Can I keep editing in Lovable after moving to Netlify?
Is Netlify free for a Lovable app?
What if my app uses Supabase edge functions?
Why does my Netlify deploy return 404 on nested routes?
How do I add environment variables to Netlify after the first deploy?
Can I use Netlify Forms with my Lovable app?
How do I handle Stripe webhook updates after moving to Netlify?
Why do my env vars work in Netlify's preview deploy but not in production?
Does Netlify's free plan limit how many times I can redeploy during a migration?
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.