How to Self-Host a Lovable App: Front End and Backend
Last updated: By The Migrator Team
To self-host a Lovable app you need to solve two separate problems: where the front end runs, and where the backend lives. The good news is that a Lovable app is a standard React and Vite project, so it runs almost anywhere once you have the code.
This guide covers both halves, from the quickest option (your own Supabase project and a static host) to full self-hosting on a server you control. If your main worry is vendor lock-in or moving your app to your own hosting, this is the page to follow, and the migration tool handles the backend move for you.
What self-hosting a Lovable app really means
A Lovable app has a front end (the pages and logic users see) and a backend (database, users, files and functions). Self-hosting means you run both on infrastructure you choose instead of relying on a managed environment.
There is a spectrum. Most people stop at the middle option, which removes day-to-day dependence while keeping operations simple.
- Option 1: own Supabase project + managed static host. Front end on Vercel, Netlify or Cloudflare Pages, backend on your own Supabase account. Easiest and cheapest to operate.
- Option 2: own Supabase project + your own server. Front end served by nginx or Caddy on a VPS, backend still on Supabase.
- Option 3: everything on your server. Front end and a self-hosted Supabase (open source) running in Docker.
Step 1: Export the code and the backend
1Get the code
Connect the project to GitHub and download it, as described in how to export your Lovable project.

Repository downloaded as a ZIP when you self-host a Lovable app 2Move the backend
Create your own Supabase project and migrate the database, users, files and functions with the complete migration guide or the free tool.
Step 2: Build the front end
Set the three environment variables for your new backend in a .env file, then build. Vite bakes these values into the build, so you must rebuild whenever they change.
echo 'VITE_SUPABASE_URL="https://YOUR_REF.supabase.co" VITE_SUPABASE_PUBLISHABLE_KEY="your-publishable-key" VITE_SUPABASE_PROJECT_ID="YOUR_REF"' > .env npm install npm run build # outputs the static site to dist/
Step 3: Host the static files
The dist folder is plain HTML, CSS and JavaScript. Upload it to any static host. Because the app is a single-page app, configure the host to serve index.html for unknown paths, otherwise a refresh on a deep link shows a 404.
- Vercel, Netlify, Cloudflare Pages: connect the repository, set the build command to
npm run buildand the output folder todist, and add the three environment variables in the dashboard. - Your own server: copy
distto the server and serve it with nginx, as below.
server {
listen 80;
server_name your-domain.com;
root /var/www/your-app/dist;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}Step 4 (optional): Self-host Supabase itself
If you need the backend on your own servers too, Supabase is open source and can be run with Docker. This gives you the most control and the most responsibility: you handle backups, upgrades, security patches, monitoring and scaling. Follow the official self-hosting guide, and move your data with the same schema, CSV and users steps as above.
Most teams find that a managed Supabase project plus their own front-end hosting is the right balance. Self-host the backend only if you have a clear compliance or cost reason and someone to operate it.
Checklist before you switch DNS
Frequently asked questions
Can I self-host a Lovable app?
Yes. A Lovable app is a standard React and Vite project. Export the code from GitHub, build it and host the static files anywhere, with your backend on your own Supabase project.
Do I have to self-host the database too?
No. Most people use their own managed Supabase project. Self-hosting Supabase with Docker is optional and adds operational work.
Why does my self-hosted app show a 404 on refresh?
It is a single-page app. Configure your host to serve index.html for unknown paths, as in the nginx example.
Why does my build still use the old backend?
Vite bakes environment variables into the build. Change them in .env or your host settings and rebuild.
Is self-hosting cheaper?
A static host plus a Supabase project is often inexpensive, but full self-hosting adds your time for maintenance. Compare using the pricing guide.
Related guides
How to Migrate from Lovable Cloud to Supabase
The complete pillar guide: schema, data, users, files and functions, end to end.
How to Export Your Lovable Project: Code, Data and Files
Everything you can export from Lovable: code, database, users, files, plus a backup checklist.
How to Connect Your Lovable App to Your New Supabase Project
Update .env and config.toml, redeploy and test the switch safely.