Skip to main content

What Breaks

The CLI handles the mechanical transformation, but some Lovable-specific patterns require manual fixes. Here’s what to watch for.

Hardcoded API Calls

Lovable-Managed Endpoints

Lovable apps often have hardcoded references to Lovable’s managed backend:
Fix: Update to your own API or Supabase:

Supabase Client Configuration

Fix: Update to your own Supabase project:

Environment Variables

Lovable-Specific Variables

Lovable injects environment variables at build time that won’t exist in your Next.js app:
Fix: Create your own .env.local:
Prefix changes:
  • Vite uses VITE_ prefix
  • Next.js uses NEXT_PUBLIC_ prefix for client-side env vars

Missing Environment Variables

After conversion, your app won’t have access to Lovable’s injected variables. You’ll need to:
  1. Create .env.local file
  2. Add your Supabase credentials
  3. Update any hardcoded URLs
  4. Restart dev server

Route Structure Changes

React Router → Next.js App Router

The CLI converts React Router patterns, but you need to understand the new structure:
Becomes: File-based routing in app/ directory

Route Parameters

Data Fetching Patterns

Client-Side Fetching in useEffect

Optimization: Use Server Components for data fetching:

Realtime Subscriptions

Authentication Patterns

Client-Side Auth State

Better: Use middleware for route protection:

Database Queries

Hardcoded Table Names

Make sure your table names match your Supabase schema:

RLS Policy Dependencies

If you’re still on Lovable’s backend temporarily:
Fix: Either migrate to your own Supabase with proper RLS, or use service role key for admin operations.

Styling Issues

Tailwind Classes

Most Tailwind classes work, but check for:

Font Imports

Image Handling

Standard img Tags

Better: Use Next.js Image component:

External Images

Build Errors

”window is not defined”

Cause: Browser API used in Server Component
Fix: Add ‘use client’ or use dynamic import:

“document is not defined”

Same fix as above - either add ‘use client’ or ensure code runs only in browser.

”Cannot find module”

Cause: Old import paths from Vite structure
Fix: Update tsconfig.json or next.config.js:

Post-Conversion Checklist

1

Update environment variables

Create .env.local with your Supabase credentials
2

Update Supabase client config

Change from Lovable’s Supabase URL to your own
3

Update API endpoints

Change any hardcoded /api/ calls to your own backend
4

Review data fetching

Consider moving fetch calls to Server Components
5

Add middleware for auth

Protect routes at the edge instead of client-side
6

Test auth flow

Verify login/logout works with your Supabase
7

Update image components

Replace <img> with Next.js <Image>
8

Run the build

npm run build to catch any remaining issues
9

Test in production mode

npm start after building to test the real thing

Common Error Messages

”Failed to fetch”

Cause: API endpoint doesn’t exist or CORS error Fix: Check that your Supabase URL is correct and accessible

”Auth session missing”

Cause: Auth state not persisting or wrong Supabase project Fix: Verify you’re connecting to the right Supabase instance

”Row level security violation”

Cause: RLS policies blocking your query Fix: Check RLS policies in your Supabase dashboard, or use service role for admin ops

”relation does not exist”

Cause: Table name typo or schema mismatch Fix: Check exact table names in Supabase, case-sensitive!
Still stuck? Check the Troubleshooting guide or use our Cloud Migration Extension to move your backend too.