Before you migrate
This guide is intended for teams with specific requirements, such as compliance constraints, data residency needs, or organizational infrastructure policies, that require running parts of an application outside Lovable Cloud. Lovable Cloud already provides an integrated development and production environment, including:- Production hosting with custom domains and automatic SSL
- Automated deployments and environment management
- Managed authentication with row-level security
- Database and file storage
- Automatic preview environments for every change
- AI agent with debugging in preview and development environments
- Managed AI provider access for runtime features
- Built-in OAuth configuration and token refresh
- Security scanning and compliance-ready infrastructure (SOC 2 Type 2, ISO 27001)
Prerequisite: Connect your project to GitHub
All scenarios in this guide require connecting your project to GitHub. When GitHub is connected:- Your Lovable project stays in continuous sync with your repository
- External platforms deploy directly from GitHub
- Lovable continues to manage development, previews, and tooling independently
Host the production frontend on a managed platform
This is the most common first step when moving outside Lovable Cloud. You deploy the production frontend to a managed hosting platform while continuing to use Lovable for development and previews. Your backend and data can remain on Lovable Cloud or run elsewhere.What you’re responsible for
When the production frontend runs outside Lovable Cloud, you are responsible for:- Frontend deployment pipelines and rollbacks
- Production environment variables
- CDN behavior and caching
- Frontend availability and uptime
- Production logs and deployment history
- Preview environments for production branches or releases
Common approaches
- Git-based hosting platforms
These platforms connect directly to your GitHub repository and automatically build and deploy on each push:- Netlify
- Cloudflare Pages
- Vercel
- AWS Amplify Hosting
- Azure Static Web Apps
- Google Firebase Hosting
- Object storage + CDN hosting
These platforms host static files behind a CDN but require a build pipeline to generate and upload thedist/output.- AWS: S3 + CloudFront
- Google Cloud: Cloud Storage + Cloud CDN
- Azure: Azure Storage (Static Website) + Azure CDN or Front Door
Deploying to a Git-based hosting platform
This approach applies to platforms that automatically build and deploy from your GitHub repository.Example: Deploying to a Git-based hosting platform
Example: Deploying to a Git-based hosting platform
Configure build settings
- Build command:
npm run build - Output directory:
dist - Node version: 22
Configure environment variables
.env file:.env file in Lovable’s code editor or in your synced GitHub repository.Configure SPA routing
404, configure a fallback rewrite so all routes serve /index.html. The method varies by platform (for example, _redirects file on Netlify/Cloudflare, staticwebapp.config.json on Azure, rewrite rules on Amplify, vercel.json on Vercel, firebase.json on Firebase).Update OAuth redirect URLs
Deploying to object storage + CDN with CI/CD
CDN-backed hosting requires a CI/CD pipeline to build your app and upload thedist/ output. Build steps are identical across providers. Deployment is provider-specific, see links to official documentation for each platform.
Example: Deploying to object storage + CDN with CI/CD
Example: Deploying to object storage + CDN with CI/CD
- AWS: Use IAM roles with OIDC
- Google Cloud: Workload Identity Federation
- Azure: Federated identity credentials
Add GitHub secrets
| Secret | Value |
|---|---|
VITE_SUPABASE_URL | Your Supabase project URL (from your project’s .env file) |
VITE_SUPABASE_PUBLISHABLE_KEY | Your Supabase publishable key (from your project’s .env file) |
Add provider-specific deployment steps
| Platform | Documentation |
|---|---|
| AWS S3 + CloudFront | Deploying to Amazon S3, GitHub Actions for AWS |
| Google Cloud Storage | Hosting a static website, GitHub Actions for Google Cloud |
| Azure Blob Storage | Static website hosting in Azure Storage, GitHub Actions for Azure |
Configure SPA routing
index.html with a 200 status code for routes that don’t match a file. This is typically configured as:- A custom error response returning 200 (CloudFront)
- A URL rewrite rule on a load balancer (Cloud CDN)
- A URL rewrite rule (Front Door)
Host the production frontend on your own infrastructure
Use this approach when you need full control over frontend hosting, networking, or runtime environment. This is sometimes referred to as self-hosting. The frontend is built from your GitHub repository and deployed to infrastructure you manage. The backend and data can remain on Lovable Cloud or run elsewhere.What you’re responsible for
When the production frontend runs on infrastructure you manage, you are responsible for:- Build and deployment automation
- SSL/TLS configuration
- CDN and reverse proxy configuration
- Monitoring, logging, and uptime
- Infrastructure updates and security
- Preview environments for branches or releases
Common approaches
- Container-based deployments
For example: Docker deployed via Kubernetes (EKS, GKE, AKS), ECS, Nomad, or internal container platforms - Virtual machines behind a web server
For example: Linux VMs running Nginx or Apache, managed through configuration management or internal tooling - Internal PaaS platforms
For example: company-internal deployment platforms or private cloud PaaS solutions
Build requirements
Lovable projects are standard Vite applications and build as static frontends.- Build command:
npm run build - Output directory:
dist/ - Node version: 22 recommended
VITE_ are embedded at build time, not runtime.
If using Lovable Cloud as your backend, you must set these before running npm run build:
VITE_SUPABASE_URLVITE_SUPABASE_PUBLISHABLE_KEY
.env file.
Container-based deployment (Docker)
Example: Manual Docker deployment
Example: Manual Docker deployment
Create a Dockerfile
npm run build, and the second stage serves the static output with nginx.Here’s an example Dockerfile you can adapt:Create an nginx configuration file
index.html for all routes. Create an nginx.conf file:Example: Automated Docker deployment (CI/CD)
Example: Automated Docker deployment (CI/CD)
- AWS ECR: Use IAM roles with OIDC
- Google Artifact Registry: Workload Identity Federation
- Azure Container Registry: Federated identity credentials
- GitHub Container Registry: Use GITHUB_TOKEN (no secrets needed)
- A container registry (for example, GitHub Container Registry, AWS ECR, Google Artifact Registry, Azure Container Registry, Docker Hub)
- The
Dockerfileandnginx.conffiles from the manual container-based deployment section above - An orchestration platform to deploy the container (for example, Kubernetes, ECS)
Add GitHub secrets
| Secret | Value |
|---|---|
VITE_SUPABASE_URL | Your Supabase project URL (from your project’s .env file) |
VITE_SUPABASE_PUBLISHABLE_KEY | Your Supabase publishable key (from your project’s .env file) |
Create the workflow file
.github/workflows/deploy-container.yml in your repository:Configure registry authentication
| Registry | Documentation |
|---|---|
| GitHub Container Registry | Authenticating with GITHUB_TOKEN |
| AWS ECR | Amazon ECR Login Action |
| Google Artifact Registry | Google Auth Action |
| Azure Container Registry | Azure Login Action |
| Docker Hub | Docker Login Action |
VM or static server deployment
Example: Manual VM or static server deployment
Example: Manual VM or static server deployment
Build the application with environment variables
dist/ directory.Configure your web server
index.html for all routes.Example nginx configuration:Configure TLS (recommended)
Host backend and data on a managed provider (Supabase example)
This option is typically chosen when you need direct database access, advanced database features, or clearer separation of infrastructure ownership, without taking on full operational responsibility. You move your backend services and database to a managed backend provider. The most direct migration path is to managed Supabase, which closely matches Lovable Cloud’s default backend architecture. The production frontend can run on Lovable Cloud or elsewhere. After migration:- The production frontend needs to point to the new backend
- You can continue using the Lovable editor and preview environments during development
What you’re responsible for
When your backend runs outside Lovable Cloud, you are responsible for the backend capabilities Lovable previously managed, including:- Database availability, scaling, and backups
- Backend monitoring and incident response
- Row-level security configuration and maintenance
- Authentication provider configuration
- OAuth credentials, redirect URLs, and secret rotation
- Backend environment variables and configuration
- Security scanning for misconfigurations and exposed secrets
- Compliance posture of your backend infrastructure
What migrates and how
| App components | Migration method | Notes |
|---|---|---|
| Database schema | Automatic via SQL migrations | Includes tables, columns, indexes, RLS policies, functions, triggers |
| Storage buckets | Automatic via SQL migrations | Includes access policies |
| Authentication providers | Manual | Reconfigure auth (for example, Google OAuth, GitHub) in your new hosting environment |
| Environment variables and secrets | Manual | Reconfigure any API keys, tokens, or credentials for external services (for example, Stripe) in your new hosting environment |
| Data (table contents) | Manual | Export/import as CSV |
| Storage files | Manual | Download/upload manually |
| User accounts | Manual, partial | You can export user data from the database, but you cannot export user passwords, so you need to trigger a password reset flow. We recommend you plan the migration before onboarding real users. |
Manual migration using the Supabase dashboard
Manual migration using the Supabase dashboard
Create a new Supabase project
- Go to supabase.com → New project
- Choose your organization and fill in:
- Project name: any name
- Database password: strong password
- Region: closest to your users
- Click Create new project and wait around 2 minutes for the project to initialize.
- From your new Supabase project settings, save these values:
- Project ID
- Public API Key (anon key)
- Project URL:
https://[your-project-id].supabase.co
Update environment variables
.env file.- In your Lovable project, go to Code.
-
Locate
.envfile. -
Update Lovable Cloud values with new Supabase credentials:
- Save changes.
Update Supabase configuration
supabase/config.toml file.- In your Lovable project, go to Code.
-
Locate
supabase/config.tomlfile. -
Update Lovable Cloud project ID with new Supabase project ID:
- Save changes.
Run database migrations
supabase/migrations/ folder.Run them in chronological order based on the timestamp in the filename. They are ordered from earliest to latest. For example:- Copy the entire SQL content from each migration file.
- Paste it into the SQL editor in your new Supabase project.
- Run and wait for success message.
Export and import your data
- Go to Cloud → Database → Table.
- Click Export CSV.
- Save the file.
- Go to Table Editor.
- For each table, click Insert → Import data from CSV.
- Map columns correctly.
- Click Import data.
Reconfigure authentication
- In your new Supabase project, go to Authentication → Sign In / Providers.
- Enable and configure each provider.
- In your OAuth app settings (for example, Google Console, GitHub), update redirect URLs to use your new Supabase project URL.
Migrate storage files
- In your Lovable project, go to Cloud → Storage.
- Download files from your storage buckets.
- In Supabase, go to Storage and upload files to corresponding buckets.
Set up environment variables and secrets
- In your new Supabase project, go to Edge Functions → Manage Secrets.
- Add any API keys or external service credentials.
- Save changes.
Advanced migration using the Supabase CLI
Advanced migration using the Supabase CLI
Host backend and data on your own infrastructure (Supabase example)
This option is intended for strict compliance, data residency, or infrastructure control requirements. You run the backend and database on infrastructure you operate. The most direct self-hosted path is self-hosted Supabase, which provides the authentication, storage, realtime, and edge function services that Lovable applications depend on. The production frontend can remain on Lovable Cloud or elsewhere. Lovable can still be used for development, or development can fully transition to other tools. Running only a standalone PostgreSQL database is not sufficient unless you implement equivalent authentication, storage, realtime, and edge services.What you’re responsible for
When the backend runs on infrastructure you operate, you are responsible for the backend capabilities Lovable previously managed, including:- PostgreSQL operations, backups, and disaster recovery
- Authentication, storage, and realtime service availability and reliability
- Row-level security design and enforcement
- Applying security patches and managing version upgrades
- Edge function deployment and execution
- Performance tuning and scaling
- Monitoring, alerting, and incident response
- Compliance certification of your infrastructure
-
Deploy Supabase in your own infrastructure using Supabase’s official self-hosting with Docker guide.
You can generate these Docker configurations directly with the Lovable agent. See Using Lovable to generate Docker deployments below.
- Configure PostgreSQL, authentication, storage, and required services.
-
Apply the migration files from your Lovable project (
supabase/migrations/) to your self-hosted instance. -
Update your application environment variables to point at your self-hosted Supabase:
Using Lovable to generate Docker deployments
If you prefer a containerized deployment, you can prompt Lovable to generate Docker and Docker Compose configurations for your project. The agent will provide generated file details, service ports, and run commands in chat. Below are the three supported patterns.Frontend only
Package just the React app as a static site served by Nginx. Use this when you only want to move your frontend. For example:Backend only (self-hosted Supabase)
Run the full Supabase stack locally without bundling the frontend. Use this when you want to develop the frontend separately or serve it from another host. For example:Full stack (frontend + self-hosted Supabase)
Bundle the frontend and a self-hosted Supabase stack in a single Docker Compose setup. Use this for fully self-contained deployments. For example:Manual configuration required for self-hosted Supabase
The agent generates placeholder secrets that must be replaced before use:- Generate a JWT secret:
openssl rand -base64 32 - Generate API keys using your JWT secret. Follow the Supabase self-hosting documentation for generating API keys.
- Replace the following values in
docker-compose.yml:JWT_SECRETPOSTGRES_PASSWORDANON_KEYSERVICE_ROLE_KEY
Limitations
- The agent cannot run or test Docker builds. You must verify locally.
- The agent cannot generate real secrets. Placeholders require manual replacement.