Key Takeaways
- ?? Ownership: Lovable code is 100% yours. Connect to GitHub or download the ZIP for complete freedom.
- ?? Hosting flexibility: Deploy the React/Vite frontend to Vercel, Netlify, Railway, Render, or even a VPS/Docker.
- ?? Environment Secrets: Always prefix frontend secrets with
VITE_and configure them in your host's dashboard. - ??? Database: Keep Supabase managed, or self-host Postgres if you need full control.
Lovable is an incredible AI-powered builder that can turn natural language prompts into full-stack web applications. In minutes, you can go from an idea to a working MVP with authentication, a database, and an intuitive UI. But what happens when you want to take your prototype to the next level?
Exporting your Lovable code gives you 100% ownership, deployment flexibility, and scalability. This guide walks through exactly how to extract your app from Lovable Cloud and run it anywhere.
Why Export Your Code?
Hosting on Lovable Cloud is convenient initially, but as you scale, self-hosting provides:
- Zero Lock-In: Your codebase uses standard technologies (React, Vite, Tailwind CSS, shadcn/ui).
- Customization: Integrate external APIs, payment gateways (like Stripe), and custom libraries not natively supported by Lovable.
- Cost Savings: Moving to platforms with robust free tiers or cheaper scaling can reduce per-user costs.
- Data Control: Host your database in specific regions to comply with GDPR or HIPAA.
Step-by-Step Export Process
Lovable generates production-ready code that you can extract via GitHub or direct download. We highly recommend using GitHub integration for two-way sync:
Step 1: In your Lovable project, go to Settings ? Integrations and enable GitHub.
Step 2: Authorize Lovable to create a new repository and push the code.
Step 3: Clone the repo locally: git clone https://github.com/your-username/your-project.git.
Step 4: Run npm install to install all dependencies listed in your package.json.
Managing Environment Variables
One critical step often missed is managing secrets. Lovable does not export your API keys. You must create a .env.local file in your local environment.
Remember that frontend variables must be prefixed with VITE_. For example:
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key
In your React code, always use import.meta.env.VITE_SUPABASE_URL instead of process.env to avoid build errors.
Deploying to Vercel, Netlify, and Others
Because Lovable projects are static Vite React apps, deployment is straightforward across major hosts:
Vercel & Netlify
Import your GitHub repo, confirm the framework is set to Vite, and ensure the Build Command is npm run build and the Output Directory is dist. Don't forget to add your VITE_ environment variables in their respective dashboards before deploying.
Railway & Render
For Render, add a redirect rule for Single Page Applications (SPAs): source /* to destination /index.html. Railway offers an all-in-one approach where you can deploy the static site alongside a Postgres plugin if you want to migrate your database off Supabase.
VPS or Docker
For maximum control, use a multi-stage Dockerfile that runs npm run build and serves the dist/ folder using Nginx. Configure Nginx to route all traffic back to index.html to prevent 404 errors on React routes.
Common Pitfalls & SEO Best Practices
- Blank Pages on Refresh: Ensure you configure a rewrite/redirect rule (like Netlify's
_redirects) pointing all paths toindex.html. - CORS Errors: Add your new custom domain to the allowed CORS/redirect URLs in your Supabase dashboard.
- SEO Enhancements: Lovable generates client-side rendered (CSR) apps. To improve SEO, update metadata in
public/index.htmland consider pre-rendering static content using tools likevite-plugin-prerender-spa.
Take Back Control
Exporting your Lovable project and hosting it externally is the turning point where your AI prototype becomes a real, scalable application. You are no longer constrained by a platform's limitations. Connect your repo, push to a static host, configure your custom domain, and start building out your business with complete ownership.