Deploy a Lovable app to a VPS: GitHub sync, build, domain
How to deploy a Lovable app to a VPS: sync it to GitHub, tell a Vite app from TanStack Start, keep or move the Supabase backend, then build, route and add SSL.

Key takeaways
- Lovable's GitHub sync is two-way, works on all plans, always creates a new private repository and syncs one branch, by default main.
- Lovable apps created from May 13, 2026 use TanStack Start and need a Node.js server, while older apps are React + Vite and build to static files in dist.
- VITE_ variables are embedded in the browser bundle at build time, so only the Supabase URL and publishable key belong there, never a secret key.
- The backend can stay on Lovable Cloud or Supabase while the front end moves to a VPS; moving the backend itself is a manual export and restore.
To deploy a Lovable app to a VPS, connect the project to GitHub with Lovable's two-way Git sync, clone that repository on the server, and run npm ci && npm run build. Older Lovable apps are React + Vite and produce static files in dist/ that nginx serves, with every route falling back to index.html; apps created from May 13, 2026 use TanStack Start and run as a Node.js server (node .output/server/index.mjs) behind a reverse proxy. The database, auth and storage can stay on Lovable Cloud or Supabase, so only the front end has to move.
This guide follows Lovable's own deployment docs and adds what they leave to you: the server, the domain, SSL and deploying on every push. For the wider picture (which host suits which AI-built app), start with how to deploy a vibe coded app.
Can you self-host a Lovable app?
Yes, the app, not the editor. Lovable's docs say the editor and AI agent are a managed service that cannot be self-hosted, but "the applications you build with Lovable can be hosted anywhere", and that your apps, code and content are yours. The same page lists what you take on when you leave the managed platform: production infrastructure, SSL certificates, CDN configuration, scaling, databases, backups and security monitoring.
You can keep building in Lovable after the move. Git sync is two-way, so changes made in Lovable land in GitHub and your server deploys them.
Which Lovable stack is your project?
According to Lovable's FAQ, new apps "use TanStack Start, which renders pages on the server" (from May 13, 2026, or June 22, 2026 for Enterprise workspaces), while older apps "use React + Vite and render in the browser". Lovable does not let you choose another framework. To check, open package.json:
| React + Vite (older apps) | TanStack Start (newer apps) | |
|---|---|---|
| How to recognise it | No @tanstack/react-start in dependencies |
@tanstack/react-start in dependencies |
| Build | npm run build |
npm run build, with Nitro's node-server preset on your own server |
| Output | Static files in dist/ |
A standalone .output/ folder |
| Runs as | Files served by nginx | node .output/server/index.mjs, port 3000 by default |
| Routing | Server must return index.html for every route |
The server handles routes itself |
| Supabase variables | VITE_SUPABASE_URL, VITE_SUPABASE_PUBLISHABLE_KEY |
SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY |
Lovable recommends Node 22 for both. Everything in this table comes from its external deployment guide.
How do you export a Lovable project to GitHub?
Lovable's GitHub integration is available on all plans for github.com:
- Go to Workspace settings → Git → GitHub → Add connection (or the same path under Project settings) and click Add account.
- In the GitHub popup, choose the account or organization, pick All repositories or Only select repositories, and click Install & Authorize.
- Open Project settings → Git → GitHub and click Connect next to the connection. Lovable creates a new repository and starts two-way sync.
Things worth knowing before you wire a server to it:
- Git sync always creates a new repository; it cannot attach to one that already exists, and reconnecting after a disconnect creates another new one. Your server's repository URL changes in that case.
- Repositories are private by default, so the server needs a read-only deploy key.
- Lovable syncs one branch, by default the repository's default branch (usually
main). Commits on other branches do not sync until merged. - If Lovable and GitHub diverge, Lovable pushes its changes to a
lovable-syncbranch instead of the synced branch, per the Git sync overview.
The same Git sync also works with GitLab and Bitbucket Cloud. On paid plans you can also download the whole project as a .zip, but Git sync is what makes automatic deploys possible.
Should you keep Lovable Cloud or Supabase, or self-host the backend?
Lovable's built-in backend, called Lovable Cloud in parts of the product, "utilizes Supabase's open-source foundation" and includes the database, authentication, file storage, edge functions, realtime, scheduled jobs and secrets. Projects can instead connect to your own Supabase project.
You have three options:
| Option | Effort | What changes |
|---|---|---|
| Keep the backend on Lovable Cloud | None | Only the front end moves. Backend usage keeps counting toward Lovable credits. |
| Keep or move to a hosted Supabase project | Medium | A manual migration if you start on Lovable Cloud |
| Self-host Supabase | High | You run the whole Supabase stack yourself |
For most people the first option is the right first step: move the front end, keep the backend, and revisit later.
Moving off Lovable Cloud is manual. Lovable says it "does not move a project from the built-in backend to your own Supabase project in one step". The external deployment guide describes the parts: database export as a PostgreSQL custom-format .backup (restore with pg_restore, one export every 24 hours), migrations in supabase/migrations/, storage files downloaded and re-uploaded, Edge Functions in supabase/functions/ deployed with npx supabase functions deploy, and scheduled jobs recreated. Password hashes are included, so users keep their passwords, but sessions do not carry over and sign-in providers must be set up again. App connectors, AI features and OAuth token management run through Lovable and do not migrate.
Self-hosting Supabase is a separate project. Supabase's self-hosting guide uses Docker Compose with Studio, Auth, PostgREST, Realtime, Storage and Postgres, asks for at least 4 GB RAM and 2 CPU cores (8 GB and 4 cores recommended), and says you must "never" start it with the placeholder secrets. A plain PostgreSQL database on your VPS is not a drop-in replacement, because the app also relies on Supabase Auth, Storage and its API.
Which environment variables does a Lovable app need?
The values are in the project's .env file, which you can see in Lovable's code editor or in the synced repository. For a Vite app they are VITE_SUPABASE_URL, VITE_SUPABASE_PUBLISHABLE_KEY and, during a Supabase migration, VITE_SUPABASE_PROJECT_ID.
The rule that matters: Vite exposes every VITE_ variable in client-side code and warns that they "should not contain sensitive information such as API keys". They are also embedded at build time, so changing one means rebuilding.
- The Supabase publishable key is designed for the browser. Supabase says "it only reaches what Row Level Security allows", so Row Level Security must be on for every table.
- A secret or
service_rolekey bypasses every RLS policy. Never put it in aVITE_variable, the repository or the build. - Secrets your server functions or Edge Functions read are not in the repository, and secrets stored in Lovable are not included in exports. Set Edge Function secrets in the Supabase dashboard or with
supabase secrets set; set TanStack Start server secrets on your host.
The vibe coding security checklist goes further on keys and RLS.
How to build and serve a Lovable Vite app on a VPS
On a server with Node 22 and nginx, as a non-root user:
git clone git@github.com:you/my-lovable-app.git /srv/lovable
cd /srv/lovable
cat > .env.production <<'EOF'
VITE_SUPABASE_URL=https://xxxx.supabase.co
VITE_SUPABASE_PUBLISHABLE_KEY=sb_publishable_xxx
EOF
npm ci
npm run build
npm ci needs a package-lock.json. Lovable's guide notes that if the repository only has bun.lock, you use Bun or generate and commit a package-lock.json.
Then serve dist/ with nginx. The try_files line is the SPA fallback Lovable's docs give for nginx: without it, opening /dashboard directly or refreshing it returns 404.
server {
listen 80;
server_name app.example.com;
root /srv/lovable/dist;
index index.html;
location /assets/ {
add_header Cache-Control "public, max-age=31536000, immutable";
try_files $uri =404;
}
location / {
try_files $uri $uri/ /index.html;
}
}
Vite puts hashed file names in dist/assets, so a long cache there is safe; index.html itself is not cached and picks up new builds.
How to run a TanStack Start Lovable app on a VPS
A TanStack Start app needs a running Node.js process. Lovable's guide says package.json must list nitro, and to build for your own server with:
npm ci
NITRO_PRESET=node-server npm run build
PORT=3000 HOST=127.0.0.1 node .output/server/index.mjs
Run that last command under systemd (see deploying a Node.js app to a VPS for a unit file) and proxy to it from nginx with proxy_pass http://127.0.0.1:3000;. Do not add the try_files fallback here: the server handles routing. Set SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY and any server-side secrets in the service's environment.
Custom domain, SSL and auth redirects
- Create an
Arecord for your domain pointing to the VPS (how to point a domain to a VPS). - Get a free certificate with Certbot:
sudo certbot --nginx -d app.example.com(free SSL with Let's Encrypt). - In Supabase (or the Lovable Cloud auth settings), set the Site URL and Redirect URLs to the new domain. Lovable's checklist says to confirm sign-in redirect URLs include the new domain; otherwise logins and email confirmations send users back to the old address.
Lovable's own hosting at xxx.lovable.app keeps working alongside; its docs say there is currently no way to remove that project URL.
Auto deploy on every Lovable change
Because Lovable pushes each change to the synced branch, a push webhook (or a GitHub Actions workflow) on that branch deploys every edit you make in Lovable. The pattern is the same as for any repository: build into a new folder, switch only when it works, keep the old release for rollback. Auto deploy from GitHub to a VPS has a ready-made script and the webhook verification.
Before you call it done, run Lovable's own checks: open a nested route directly and refresh it, sign in and out, test reads, writes and uploads, and for TanStack Start load a server-rendered page and trigger a server function.
Deploy a Lovable app with ZoPanel
ZoPanel's Git deploy handles the clone, build, release folders, SSL and webhook for you:
- Websites → New website, type Git deploy. Enter the repository URL in its
git@github.com:…form and the branch Lovable syncs (mainby default). Because Lovable's repositories are private, first copy the key from Deploy → Deploy key (private repositories) and add it to the repository as a read-only deploy key. - Keep Free SSL (Let's Encrypt) on and click Create website. The certificate is issued once the domain resolves to the server.
- On the Deploy tab, click Paste .env and paste the variables from Lovable's
.env, then Save & redeploy. They are available to the build, soVITE_values are embedded. - Turn on Deploy when main is pushed and add the Payload URL and Secret as a GitHub webhook (content type
application/json). Every change Lovable syncs now builds a new release; the last 5 are kept for Rollback.
For a Vite app, click Analyze repository: a project with vite and no start script is detected as Vite (React/Vue/Svelte), built with npm run build and served as a static site from dist, with hashed assets cached for 30 days and precompressed copies. From ZoPanel 0.4.35 a new website deployed this way gets the single-page app fallback by itself, so /dashboard loads on a direct visit or a reload with status 200; on an existing website, turn on Single-page app fallback on its Tools tab. Missing images, CSS and JavaScript still return 404.
For a TanStack Start app, ZoPanel 0.4.35 and later detect TanStack Start: the build runs with NITRO_PRESET=node-server (a NITRO_PRESET you set under Environment variables wins) and the app starts with node .output/server/index.mjs, or the project's own start script. Click Analyze repository to confirm before the first deploy; if the project lacks Nitro, the detection says so. On an older ZoPanel, turn Auto-detect off in Build & run and set Type to Server app (process), Build command npm run build, Start command node .output/server/index.mjs and NITRO_PRESET=node-server under Environment variables. Either way ZoPanel sets PORT and HOST=127.0.0.1 itself, which the Nitro server reads, and switches traffic only after the Health check path answers below status 500 within 90 seconds.
Two details apply to both: if the repository only has bun.lock, ZoPanel installs with npm install; and to pin Node 22, add an .nvmrc containing 22. ZoPanel does not give you a global CDN or preview deployments, and the server is yours to maintain. The vibe coding page summarises the workflow, and the Free plan covers 10 websites.
Conclusion
Moving a Lovable app to a VPS takes three decisions: which stack you have (static Vite or TanStack Start server), where the backend lives (usually: leave it on Lovable Cloud or Supabase for now), and how deploys happen (a webhook on the branch Lovable syncs). Get the VITE_ variables, the SPA fallback and the auth redirect URLs right and the rest is ordinary hosting.
FAQ
Does Lovable GitHub sync work on the free plan?
Yes. Lovable's docs list github.com sync as available on all plans. GitHub Enterprise Cloud with data residency and GitHub Enterprise Server need the Enterprise plan.
Can I connect Lovable to an existing GitHub repository?
No. Git sync always creates a new repository. To start from existing code, Lovable suggests downloading it as a ZIP, importing it into a new project and then connecting Git sync.
Will editing the code on GitHub break my Lovable project?
No, sync is two-way: changes pushed to the active branch sync back into Lovable. If both sides have commits the other lacks, Lovable pushes its changes to a lovable-sync branch instead.
Is it safe that my Supabase key is visible in the browser?
The publishable (or legacy anon) key is meant to be public, but it is only safe with Row Level Security turned on and correct policies. A secret or service_role key must never be in the front end.
Why do I get a 404 when I refresh a page of my Lovable app?
A Vite app routes in the browser, so the server must return index.html for unknown paths. Add try_files $uri $uri/ /index.html; in nginx, or the equivalent setting on your host.
Do I still pay Lovable after self-hosting?
That depends on what you keep there. Hosting the front end elsewhere does not stop backend usage on Lovable Cloud from counting toward Lovable credits, so if you keep the backend there, you keep using Lovable for it.
Put your servers on ZoPanel
Start free with 10 websites on a fresh Ubuntu or Debian server, or talk to our team about moving from cPanel, DirectAdmin or aaPanel and about licences for your business.
Free for 10 websites · No credit card · Installs in minutes
Keep reading

Deploy a Bolt.new, v0 or Replit app to your own server
How to deploy a Bolt.new, v0 or Replit app to your own VPS: export the code, fix what breaks outside the tool, then add a domain, SSL and auto deploy.

Deploy a vibe coded app: where to host what the AI built
How to deploy a vibe coded app: identify what the AI built, compare built-in hosting, Vercel, PaaS and a VPS, then fix env vars, keys and URLs before launch.

How to install a LEMP stack on Ubuntu 24.04, step by step
Install a LEMP stack on Ubuntu 24.04 (and Debian 12): firewall, nginx, MariaDB, PHP-FPM, server blocks, Let's Encrypt SSL and per-site isolation done right.