My Lovable app is broken after export — here's how to fix it
It worked perfectly in the Lovable preview. Then you exported to GitHub, tried to run it yourself — or your free credits ran out — and now it's a wall of errors. This is the single most common patient that comes through our shop. Here's the triage, in the order that actually finds the problem.
1. It won't start at all: missing environment variables
Lovable's preview quietly injects your secrets — Supabase URL and keys, API keys for
OpenAI or Stripe, auth configuration. None of those come with the export.
If your terminal or deploy log shows errors like supabaseUrl is required,
Invalid API key, or undefined is not an object the moment the app
loads, this is almost certainly it.
The fix:
- Look for a
.env.examplefile in the repo, or search the code forimport.meta.envandprocess.envto list every variable the app expects. - Create a
.env(or.env.local) file with real values. Your Supabase URL and anon key are in your Supabase dashboard under Settings → API. - When you deploy (Vercel, Netlify), add the same variables in the host's dashboard — a local
.envfile does not travel with your git push.
2. The build fails: TypeScript and dependency errors
Lovable's preview runs a dev server, which is forgiving. A production build
(npm run build) is not. Two common failures:
- TypeScript errors that the preview ignored. If there are only a handful, fix them properly. If there are hundreds, it's usually a few root causes repeated — a missing type package or a misconfigured
tsconfig.json. - Peer dependency conflicts during
npm install. AI tools pin package versions that disagree with each other.npm install --legacy-peer-depsgets you moving; the real fix is aligning the conflicting versions inpackage.json.
3. It runs, but features silently don't work
This is the sneaky tier. The app renders, looks right, and half the buttons do nothing. The usual suspects, in order of likelihood:
- Row Level Security. Supabase tables created by AI tools often have RLS enabled with no policies (every query returns empty) or RLS disabled entirely (anyone on the internet can read your whole database — check this today, not later).
- Edge functions that were never deployed. If the app calls Supabase edge functions, they live in
supabase/functions/and must be deployed separately with the Supabase CLI. The preview did this for you; your laptop doesn't. - Demo-ware. Some features were never wired to the backend at all — the AI generated a convincing UI over hardcoded data. Search the code for arrays of suspiciously realistic sample data.
4. Login broke the moment you moved it
Auth is its own category of pain — OAuth redirect URLs, site URLs, and email confirmation links are all bound to the domain the app runs on, and yours just changed. We wrote a separate deep-dive: why login doesn't work in your AI-generated app.
5. Decide: repair or rebuild?
Honest rule of thumb from the bench: if the app's data model is sound — sensible tables, real relationships — it's worth repairing, whatever the UI code looks like. If the database is a single table of JSON blobs and every feature is demo-ware, a rebuild on the same design is usually faster and cheaper than surgery. (Here's what either path actually costs.)
Or skip the triage and bring it in
Sign in with GitHub, link the repo, and we'll read your actual code — not just your description — and send a fixed quote within 48 hours. Free analysis, no retainers.
Get your free analysis →