Complete Migration Guide

    From Lovable to Next.js
    In Minutes, Not Days

    Transform your Lovable React application into a production-ready Next.js powerhouse with our automated CLI tool and comprehensive manual guide.

    500+
    Projects Migrated
    5 min
    Average CLI Migration
    100%
    Success Rate
    Choose Your Migration Path

    Two Powerful Ways to Migrate

    Select the migration approach that best fits your project timeline and requirements

    RECOMMENDED

    Automated CLI Migration

    Our intelligent CLI tool automatically converts your Lovable project structure, routing, and components to Next.js App Router format in minutes.

    5-minute complete migration
    Automatic file structure conversion
    Smart routing transformation
    Zero configuration required
    $npx @nextlovable/cli migrate
    🔍 Analyzing Lovable project structure...
    📁 Converting file structure to Next.js App Router...
    🔄 Transforming routing system...
    ⚡ Optimizing components for Next.js...
    ✅ Migration completed successfully!
    🚀 Your Next.js app is ready at: ./my-next-app
    💡 Run 'cd my-next-app && npm run dev' to start developing

    Manual Step-by-Step Guide

    Follow our comprehensive manual guide for full control over the migration process and deeper understanding of Next.js concepts.

    Complete learning experience
    Full customization control
    Detailed explanations
    Best practices included

    What You'll Learn:

    • • Next.js App Router fundamentals
    • • File-based routing system
    • • Server vs Client Components
    • • Data fetching strategies
    • • Performance optimization
    CLI Features

    Powerful CLI Commands

    Our CLI provides multiple commands to handle different migration scenarios and file conversions

    Migrate Command

    Complete project migration

    $npx @nextlovable/cli migrate [options]
    Options:
    --source, -s Source directory (default: current)
    --output, -o Output directory (default: ./migrated)
    --verbose, -v Verbose logging
    --dry-run Preview changes without writing
    Examples:
    npx @nextlovable/cli migrate -s ./my-lovable-app -o ./my-next-app
    npx @nextlovable/cli migrate --dry-run --verbose

    What it does:

    • • Converts entire Lovable project to Next.js
    • • Transforms file structure to App Router
    • • Updates routing and navigation
    • • Migrates dependencies and configurations
    NEW v0.0.7

    Convert Command

    Individual file conversion

    $npx @nextlovable/cli convert [files...] [options]
    Options:
    --output, -o Output directory
    --format, -f Output format (app-router, pages)
    --component, -c Convert to component format
    --page, -p Convert to page format
    Examples:
    npx @nextlovable/cli convert HomePage.tsx AboutPage.tsx
    npx @nextlovable/cli convert ./components/* -f app-router
    npx @nextlovable/cli convert UserProfile.tsx --page

    Perfect for:

    • • Converting specific React components
    • • Updating individual pages
    • • Gradual migration approach
    • • Testing conversion on single files
    Latest Version: v0.0.7View Full Documentation →
    Why Migrate?

    Transform Your Development Experience

    Discover the powerful advantages of migrating from Lovable React to Next.js

    Improved Performance

    Automatic image optimization, code splitting, and built-in performance optimizations that significantly improve your app's speed and user experience.

    Server-Side Rendering

    Boost SEO and initial load times with built-in SSR capabilities, moving beyond Vite's client-side only rendering limitations.

    Hybrid Rendering

    Choose between static generation, server-side rendering, or incremental static regeneration on a per-page basis for optimal performance.

    File-Based Routing

    Next.js's intuitive file-based routing system eliminates complex route configurations while providing powerful routing capabilities.

    Built-in API Routes

    Create backend API endpoints directly within your Next.js application without setting up a separate server infrastructure.

    Production Ready

    Next.js is battle-tested at scale and designed for production environments with built-in optimizations and deployment integrations.

    Manual Migration

    Step-by-Step Manual Guide

    For those who prefer to understand every step or need custom configurations

    1

    Project Setup

    Create a new Next.js project and prepare your environment for the migration process.

    $npx create-next-app@latest my-next-app --typescript --tailwind --eslint --app
    ✓ Creating a new Next.js app in /my-next-app
    ✓ Installing dependencies with npm...
    ✓ Initializing project with template
    ✓ Installation complete!
    Success! Created my-next-app at /my-next-app
    🚀 Get started by navigating to the directory:
    cd my-next-app
    npm run dev
    2

    Dependencies Transfer

    Copy your dependencies from package.json and install them in your new Next.js project.

    Before (Lovable/Vite)

    json
    {
      "dependencies": {
        "react": "^18.2.0",
        "react-dom": "^18.2.0",
        "react-router-dom": "^6.8.1",
        "vite": "^4.1.0",
        "@vitejs/plugin-react": "^3.1.0"
      }
    }

    After (Next.js)

    json
    {
      "dependencies": {
        "next": "^14.0.0",
        "react": "^18.2.0",
        "react-dom": "^18.2.0",
        "typescript": "^5.0.0",
        "@types/node": "^20.0.0",
        "@types/react": "^18.0.0"
      }
    }
    3

    File Structure Migration

    Convert your Lovable project structure to Next.js App Router format.

    Lovable Structure

    text
    src/
    ├── components/
    │ ├── HomePage.tsx
    │ ├── AboutPage.tsx
    │ └── ContactPage.tsx
    ├── App.tsx
    ├── main.tsx
    └── index.css

    Next.js App Router

    text
    app/
    ├── page.tsx # Home page
    ├── about/
    │ └── page.tsx # About page
    ├── contact/
    │ └── page.tsx # Contact page
    ├── layout.tsx # Root layout
    └── globals.css
    4

    Routing Conversion

    Replace React Router with Next.js file-based routing system.

    Remove React Router (Before)

    tsx
    // App.tsx - Remove this
    import { BrowserRouter, Routes, Route } from 'react-router-dom';
    function App() {
      return (
        <BrowserRouter>
          <Routes>
            <Route path="/" element={<HomePage />} />
            <Route path="/about" element={<AboutPage />} />
            <Route path="/contact" element={<ContactPage />} />
          </Routes>
        </BrowserRouter>
      );
    }

    Use File-Based Routing (After)

    tsx
    // app/layout.tsx - Root layout
    export default function RootLayout({
      children,
    }: {
      children: React.ReactNode
    }) {
      return (
        <html lang="en">
          <body>{children}</body>
        </html>
      )
    }
    // app/page.tsx - Home page (automatically routes to /)
    export default function HomePage() {
      return <div>Welcome to my Next.js app!</div>
    }
    // app/about/page.tsx - About page (automatically routes to /about)
    export default function AboutPage() {
      return <div>About us</div>
    }
    5

    Component Migration & Server vs Client

    Convert your React components to work with Next.js App Router and understand Server vs Client components.

    Server Components (Default)

    tsx
    // app/components/UserProfile.tsx - Server Component
    import { getUserById } from '@/lib/api'
    export default async function UserProfile({ userId }: { userId: string }) {
      // Data fetching directly in Server Component
      const user = await getUserById(userId)
      
      return (
        <div className="p-6 bg-white rounded-lg shadow">
          <h2 className="text-xl font-bold">{user.name}</h2>
          <p className="text-gray-600">{user.email}</p>
          <UserInteractiveSection user={user} />
        </div>
      )
    }

    Client Components (When Needed)

    tsx
    'use client' // Required for interactivity
    import { useState } from 'react'
    import { Button } from '@/components/ui/button'
    export function UserInteractiveSection({ user }: { user: User }) {
      const [isEditing, setIsEditing] = useState(false)
      
      const handleEdit = () => {
        setIsEditing(!isEditing)
      }
      
      return (
        <div className="mt-4">
          <Button onClick={handleEdit}>
            {isEditing ? 'Save' : 'Edit Profile'}
          </Button>
          {isEditing && (
            <form className="mt-4">
              {/* Edit form */}
            </form>
          )}
        </div>
      )
    }
    6

    Data Fetching & API Routes

    Implement Next.js data fetching patterns and create API routes for your backend logic.

    API Routes

    tsx
    // app/api/users/route.ts
    import { NextRequest, NextResponse } from 'next/server'
    export async function GET() {
      try {
        const users = await fetchUsers()
        return NextResponse.json({ users })
      } catch (error) {
        return NextResponse.json(
          { error: 'Failed to fetch users' },
          { status: 500 }
        )
      }
    }
    export async function POST(request: NextRequest) {
      const data = await request.json()
      const user = await createUser(data)
      return NextResponse.json({ user }, { status: 201 })
    }

    Client-side Fetching

    tsx
    'use client'
    import { useState, useEffect } from 'react'
    export function UsersList() {
      const [users, setUsers] = useState([])
      const [loading, setLoading] = useState(true)
      
      useEffect(() => {
        fetch('/api/users')
          .then(res => res.json())
          .then(data => {
            setUsers(data.users)
            setLoading(false)
          })
      }, [])
      
      if (loading) return <div>Loading...</div>
      
      return (
        <div>
          {users.map(user => (
            <UserCard key={user.id} user={user} />
          ))}
        </div>
      )
    }
    7

    Navigation & Links

    Update navigation components to use Next.js Link component and navigation patterns.

    Before (React Router)

    tsx
    import { Link, useNavigate } from 'react-router-dom'
    function Navigation() {
      const navigate = useNavigate()
      
      return (
        <nav>
          <Link to="/">Home</Link>
          <Link to="/about">About</Link>
          <button onClick={() => navigate('/contact')}>
            Contact
          </button>
        </nav>
      )
    }

    After (Next.js)

    tsx
    'use client'
    import Link from 'next/link'
    import { useRouter } from 'next/navigation'
    function Navigation() {
      const router = useRouter()
      
      return (
        <nav>
          <Link href="/">Home</Link>
          <Link href="/about">About</Link>
          <button onClick={() => router.push('/contact')}>
            Contact
          </button>
        </nav>
      )
    }
    8

    Styling & Assets Migration

    Move your CSS files, configure Tailwind CSS, and optimize images with Next.js Image component.

    CSS & Styling

    tsx
    // Move CSS files
    src/index.css → app/globals.css
    // Import in layout.tsx
    import './globals.css'
    // For component-specific styles
    import styles from './HomePage.module.css'
    // Or use Tailwind CSS classes
    <div className="bg-blue-500 text-white p-4 rounded-lg">
      Next.js with Tailwind
    </div>

    Image Optimization

    tsx
    // Before (regular img tag)
    <img src="/hero-image.jpg" alt="Hero" />
    // After (Next.js Image)
    import Image from 'next/image'
    <Image
      src="/hero-image.jpg"
      alt="Hero"
      width={800}
      height={600}
      priority // For above-the-fold images
      className="rounded-lg"
    />
    9

    Metadata & SEO

    Configure page metadata, SEO optimization, and social sharing for better search engine visibility.

    tsx
    // app/layout.tsx - Global metadata
    import type { Metadata } from 'next'
    export const metadata: Metadata = {
      title: 'My Next.js App',
      description: 'A powerful Next.js application',
      keywords: 'nextjs, react, web development',
      authors: [{ name: 'Your Name' }],
      openGraph: {
        title: 'My Next.js App',
        description: 'A powerful Next.js application',
        url: 'https://myapp.com',
        images: ['/og-image.jpg'],
      },
      twitter: {
        card: 'summary_large_image',
        title: 'My Next.js App',
        description: 'A powerful Next.js application',
        images: ['/twitter-image.jpg'],
      },
    }
    // app/about/page.tsx - Page-specific metadata
    export const metadata: Metadata = {
      title: 'About Us - My Next.js App',
      description: 'Learn more about our company and team',
    }
    10

    Environment Configuration & Deployment

    Set up environment variables, configure Next.js settings, and prepare for deployment.

    Environment Variables

    bash
    // .env.local
    NEXT_PUBLIC_API_URL=https://api.myapp.com
    DATABASE_URL=postgresql://...
    JWT_SECRET=your-secret-key
    // .env.example (commit this)
    NEXT_PUBLIC_API_URL=https://api.example.com
    DATABASE_URL=postgresql://username:password@localhost:5432/dbname
    JWT_SECRET=your-jwt-secret-here
    // Use in components
    const apiUrl = process.env.NEXT_PUBLIC_API_URL
    const dbUrl = process.env.DATABASE_URL // Server-only

    Next.js Configuration

    javascript
    // next.config.js
    /** @type {import('next').NextConfig} */
    const nextConfig = {
      images: {
        domains: ['example.com', 'cdn.myapp.com'],
        formats: ['image/webp', 'image/avif'],
      },
      env: {
        CUSTOM_KEY: process.env.CUSTOM_KEY,
      },
      // Enable experimental features if needed
      experimental: {
        serverActions: true,
      },
    }
    module.exports = nextConfig

    Deployment Commands

    $npm run build && npm run start
    ✓ Creating an optimized production build...
    ✓ Compiled successfully
    ✓ Linting and checking validity of types
    ✓ Collecting page data
    ✓ Generating static pages (5/5)
    ✓ Collecting build traces
    ✓ Finalizing page optimization
    Route (app) Size First Load JS
    ┌ ○ / 5.02 kB 87.8 kB
    ├ ○ /about 1.23 kB 84.1 kB
    └ ○ /contact 2.45 kB 85.3 kB
    ○ (Static) automatically rendered as static HTML

    Estimated Timeline

    Day 1

    Project Setup & Planning

    Set up Next.js, review structure, create migration plan

    Day 2-3

    Component Migration

    Move core components and pages from Lovable to Next.js

    Day 4-5

    Routing & Navigation

    Adapt routing system to Next.js file-based approach

    Day 6-7

    Data Fetching

    Update data fetching strategies for SSR capabilities

    Day 8-9

    Styling & Assets

    Move CSS, images, and other assets to Next.js structure

    Day 10

    Testing & Deployment

    Test application and deploy to production

    Average Manual Migration Time: 8-10 days

    Frequently Asked Questions

    Everything you need to know about migrating from Lovable to Next.js

    How many credits does my project migration cost?

    Migration costs depend on your project's size: 1-5 pages = 1 credit, 6-11 pages = 2 credits, 12-20 pages = 3 credits, and 21+ pages = 4 credits. File conversions always cost 1 credit each. Use `--dry-run` to see the exact cost before migrating.

    Is my codebase sent to any server?

    Nope. All transformations happen entirely locally on your machine. Your code is never uploaded or sent to any server—privacy and security are fully respected.

    What happens to my existing codebase?

    Your original codebase remains untouched. Next-Lovable generates a new directory with the migrated Next.js project, so you can safely test and compare without affecting your current setup.

    What about Supabase edge functions?

    They stay intact—your `supabase/functions` folder is copied over 1:1, ensuring everything continues to work as expected in the migrated project.

    Does it support complex routing?

    Yes! Next-Lovable intelligently converts React Router routes—including nested routes, dynamic parameters, and layout components—into the equivalent structure using Next.js App Router.

    What about my third-party dependencies?

    Next-Lovable inspects your `package.json`, updates dependencies to Next.js-compatible versions, and installs required packages automatically for a smooth transition.

    How long does the migration process take?

    For most projects, the migration completes in seconds. Larger or more complex apps might take up to a minute or two, depending on file count and code structure.

    What is the `--dry-run` flag for?

    Use `--dry-run` to simulate the migration without actually writing any files. It helps you preview changes, catch potential issues, and avoid wasting credits if something needs to be fixed first.

    Still have questions?

    Our team is here to help you with your migration journey

    Ready to Transform Your App?

    Upgrade to Next.js Today

    Choose automated CLI migration for instant results, or follow our comprehensive manual guide. Transform your Lovable React application into a production-ready Next.js powerhouse.

    500+
    Projects Migrated
    5 min
    Average CLI Migration
    100%
    Success Rate