Skip to content

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

  1. 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
    Repository downloaded as a ZIP when you self-host a Lovable app
  2. 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.

Terminal: build the app
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 build and the output folder to dist, and add the three environment variables in the dashboard.
  • Your own server: copy dist to the server and serve it with nginx, as below.
nginx: serve a single-page app
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

  • The app loads and you can sign in against the new backend.
  • Auth redirect URLs and the Site URL in Supabase point to your real domain.
  • Edge functions are deployed and their secrets are set.
  • HTTPS is enabled, and deep links work after a refresh.
  • You have a backup and a way to roll back.

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.