<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mihailo Popović</title>
    <description>The latest articles on DEV Community by Mihailo Popović (@softzer0).</description>
    <link>https://dev.to/softzer0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4239116%2F045041e8-8325-4364-b43f-aedca9d8a849.jpg</url>
      <title>DEV Community: Mihailo Popović</title>
      <link>https://dev.to/softzer0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/softzer0"/>
    <language>en</language>
    <item>
      <title>Deploy Next.js to a VPS with Docker and HTTPS</title>
      <dc:creator>Mihailo Popović</dc:creator>
      <pubDate>Fri, 27 Nov 2026 18:39:48 +0000</pubDate>
      <link>https://dev.to/softzer0/deploy-nextjs-to-a-vps-with-docker-and-https-a7e</link>
      <guid>https://dev.to/softzer0/deploy-nextjs-to-a-vps-with-docker-and-https-a7e</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://opscrew.dev/blog/deploy-nextjs-to-a-vps/" rel="noopener noreferrer"&gt;the OpsCrew blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add &lt;code&gt;output: "standalone"&lt;/code&gt; to &lt;code&gt;next.config.ts&lt;/code&gt; so the build emits a self-contained &lt;code&gt;server.js&lt;/code&gt; that runs with plain Node.js.&lt;/li&gt;
&lt;li&gt;Build a three-stage Docker image (dependencies, build, run) that copies &lt;code&gt;.next/standalone&lt;/code&gt;, &lt;code&gt;.next/static&lt;/code&gt; and &lt;code&gt;public&lt;/code&gt;, and starts as the non-root &lt;code&gt;node&lt;/code&gt; user.&lt;/li&gt;
&lt;li&gt;Run it with Docker Compose behind Caddy, which gets the HTTPS certificate itself, and next to PostgreSQL, which publishes no port.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; variables are baked into the bundle at build time, so set them where the image is built, not on the server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To deploy Next.js to a VPS, turn on &lt;code&gt;output: "standalone"&lt;/code&gt;, build a small Docker image from the standalone output, and run it on the server with Docker Compose, next to PostgreSQL and behind Caddy, which &lt;a href="https://caddyserver.com/docs/automatic-https" rel="noopener noreferrer"&gt;gets and renews the HTTPS certificate on its own&lt;/a&gt;. Build the image in CI or on your computer, push it to a registry, point your domain at the server, and start the stack with &lt;code&gt;docker compose up -d&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Every file below was run on 11 November 2026: a fresh &lt;code&gt;create-next-app&lt;/code&gt; project (Next.js 16.4.6) built into an image on Node.js 24.22.2, then run with PostgreSQL 18.6 and Caddy 2.11.9 under Docker 29.9.3. It is one part of &lt;a href="https://opscrew.dev/blog/deploy-web-app-to-a-vps/" rel="noopener noreferrer"&gt;our complete guide to deploying a web app to a VPS&lt;/a&gt;, which covers choosing the server, DNS, backups and hardening around it.&lt;/p&gt;

&lt;p&gt;If v0 or another AI builder generated your Next.js app, read &lt;a href="https://opscrew.dev/blog/deploy-v0-app-without-vercel/" rel="noopener noreferrer"&gt;how to deploy a v0 app without Vercel&lt;/a&gt; as well: it covers what those projects add on top of a plain Next.js app.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Turn on standalone output
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;create-next-app&lt;/code&gt; 16.4.6 writes a &lt;code&gt;next.config.ts&lt;/code&gt; with a few defaults of its own. Add one line, &lt;code&gt;output: "standalone"&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;NextConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"next"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;nextConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;NextConfig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"standalone"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// ...the options create-next-app wrote stay as they are&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="n"&gt;nextConfig&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this setting, &lt;code&gt;next build&lt;/code&gt; traces which files the server loads and copies them, with a minimal &lt;code&gt;server.js&lt;/code&gt;, into &lt;code&gt;.next/standalone&lt;/code&gt;. &lt;a href="https://nextjs.org/docs/app/api-reference/config/next-config-js/output" rel="noopener noreferrer"&gt;The Next.js documentation notes&lt;/a&gt; what it leaves out on purpose: the &lt;code&gt;public&lt;/code&gt; folder and &lt;code&gt;.next/static&lt;/code&gt;, which you copy next to &lt;code&gt;server.js&lt;/code&gt; yourself. The Dockerfile below does that.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Add a health route
&lt;/h2&gt;

&lt;p&gt;Docker, Caddy and your deploy script need a cheap way to ask "is this copy of the app ready?". Create &lt;code&gt;app/api/health/route.ts&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;connection&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"next/server"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// answer at request time, never from the build&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;APP_VERSION&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s2"&gt;"dev"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;await connection()&lt;/code&gt; matters in Next.js 16. Without a request-time API, Next.js may render a route once at build time and serve that copy forever, and a health check that answers from the build proves nothing. The &lt;code&gt;version&lt;/code&gt; field is optional; it helps you see which release answers.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Write the Dockerfile
&lt;/h2&gt;

&lt;p&gt;This follows the structure of &lt;a href="https://github.com/vercel/next.js/tree/canary/examples/with-docker" rel="noopener noreferrer"&gt;the official &lt;code&gt;with-docker&lt;/code&gt; example&lt;/a&gt; in the Next.js repository, cut down to npm. Put it in the project root as &lt;code&gt;Dockerfile&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# syntax=docker/dockerfile:1&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; node:24-slim AS deps
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;COPY&lt;/span&gt; package.json package-lock.json ./
&lt;span class="k"&gt;RUN&lt;/span&gt; npm ci --no-audit --no-fund

&lt;span class="k"&gt;FROM&lt;/span&gt; node:24-slim AS builder
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=deps /app/node_modules ./node_modules
&lt;span class="k"&gt;COPY&lt;/span&gt; . .
&lt;span class="k"&gt;ENV&lt;/span&gt; &lt;span class="nv"&gt;NEXT_TELEMETRY_DISABLED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;span class="k"&gt;RUN&lt;/span&gt; npm run build

&lt;span class="k"&gt;FROM&lt;/span&gt; node:24-slim AS runner
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;ENV&lt;/span&gt; &lt;span class="nv"&gt;NODE_ENV&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production \
    &lt;span class="nv"&gt;NEXT_TELEMETRY_DISABLED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 \
    &lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3000 \
    &lt;span class="nv"&gt;HOSTNAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.0.0.0
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=builder --chown=node:node /app/public ./public
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=builder --chown=node:node /app/.next/standalone ./
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=builder --chown=node:node /app/.next/static ./.next/static
&lt;span class="k"&gt;USER&lt;/span&gt; node
&lt;span class="k"&gt;EXPOSE&lt;/span&gt; 3000
&lt;span class="k"&gt;HEALTHCHECK&lt;/span&gt; --interval=5s --timeout=3s --start-period=10s --retries=3 \
  &lt;span class="k"&gt;CMD&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;, &lt;span class="s2"&gt;"-e"&lt;/span&gt;, &lt;span class="s2"&gt;"fetch('http://127.0.0.1:3000/api/health').then(r =&amp;gt; process.exit(r.ok ? 0 : 1)).catch(() =&amp;gt; process.exit(1))"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;, &lt;span class="s2"&gt;"server.js"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What each part does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;deps&lt;/code&gt;&lt;/strong&gt; installs exactly what &lt;code&gt;package-lock.json&lt;/code&gt; lists. Docker caches this layer until the lockfile changes, so code-only changes rebuild fast.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;builder&lt;/code&gt;&lt;/strong&gt; runs &lt;code&gt;next build&lt;/code&gt;. Anything the build needs, including &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; variables, must exist here (see below).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;runner&lt;/code&gt;&lt;/strong&gt; starts from a clean image and copies only the standalone server, the static files and &lt;code&gt;public&lt;/code&gt;. &lt;code&gt;HOSTNAME=0.0.0.0&lt;/code&gt; makes the server listen on every interface inside the container; Next.js's docs say &lt;code&gt;server.js&lt;/code&gt; takes its port and host name from &lt;code&gt;PORT&lt;/code&gt; and &lt;code&gt;HOSTNAME&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;HEALTHCHECK&lt;/code&gt;&lt;/strong&gt; uses Node's built-in &lt;code&gt;fetch&lt;/code&gt;, because the slim image has neither &lt;code&gt;curl&lt;/code&gt; nor &lt;code&gt;wget&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;USER node&lt;/code&gt;&lt;/strong&gt; runs the app without root privileges inside the container.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Add a &lt;code&gt;.dockerignore&lt;/code&gt;, so your local &lt;code&gt;node_modules&lt;/code&gt;, build output and secrets never enter the build context:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node_modules
.next
.git
.env*
npm-debug.log*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Build and run it locally
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build -t myapp .
docker run --rm -p 3000:3000 -e &lt;span class="nv"&gt;APP_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;v1 myapp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The image was about 385 MB on disk (93 MB compressed in the registry). In another terminal, &lt;code&gt;curl localhost:3000/api/health&lt;/code&gt; answered &lt;code&gt;{"status":"ok","version":"v1"}&lt;/code&gt; in our test, the home page answered &lt;code&gt;200&lt;/code&gt;, and &lt;code&gt;docker ps&lt;/code&gt; showed the container as &lt;code&gt;healthy&lt;/code&gt; within seconds. If the health check fails, the app is almost always listening on another port or only on &lt;code&gt;localhost&lt;/code&gt;; check &lt;code&gt;PORT&lt;/code&gt; and &lt;code&gt;HOSTNAME&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Add PostgreSQL and Caddy with Compose
&lt;/h2&gt;

&lt;p&gt;On the server, create a folder (for example &lt;code&gt;/srv/myapp&lt;/code&gt;) with three files.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;compose.yaml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ghcr.io/your-name/myapp:${APP_TAG:-latest}&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;DATABASE_URL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgresql://app:${POSTGRES_PASSWORD}@db:5432/app&lt;/span&gt;
    &lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;service_healthy&lt;/span&gt;

  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:18&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_USER&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;app&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_DB&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;app&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${POSTGRES_PASSWORD}&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;db-data:/var/lib/postgresql&lt;/span&gt;
    &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD-SHELL"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pg_isready -U app -d app"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
      &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;3s&lt;/span&gt;
      &lt;span class="na"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;

  &lt;span class="na"&gt;caddy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;caddy:2&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"80:80"&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"443:443"&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"443:443/udp"&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./Caddyfile:/etc/caddy/Caddyfile:ro&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;caddy-data:/data&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;caddy-config:/config&lt;/span&gt;
    &lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;app&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;db-data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;caddy-data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;caddy-config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Caddyfile&lt;/code&gt;, with your own domain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com {
    encode zstd gzip
    reverse_proxy app:3000
}

www.example.com {
    redir https://example.com{uri} permanent
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;.env&lt;/code&gt;, readable only by you (&lt;code&gt;chmod 600 .env&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;replace-with-the-output-of-openssl-rand-hex-24
&lt;span class="nv"&gt;APP_TAG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate the password with &lt;code&gt;openssl rand -hex 24&lt;/code&gt;; hex keeps it safe inside the &lt;code&gt;DATABASE_URL&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Notes on these files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PostgreSQL 18 mounts its volume on &lt;code&gt;/var/lib/postgresql&lt;/code&gt;.&lt;/strong&gt; &lt;a href="https://hub.docker.com/_/postgres" rel="noopener noreferrer"&gt;The official image now keeps data&lt;/a&gt; in a folder named after the major version below it; guides written for older versions mount &lt;code&gt;/var/lib/postgresql/data&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The database has no &lt;code&gt;ports:&lt;/code&gt; entry.&lt;/strong&gt; The app reaches it as &lt;code&gt;db:5432&lt;/code&gt; on Compose's network. We checked from inside the app container that &lt;code&gt;db:5432&lt;/code&gt; accepted connections; with no published port, nothing outside Compose's network can reach it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;depends_on&lt;/code&gt; with &lt;code&gt;service_healthy&lt;/code&gt;&lt;/strong&gt; starts the app only after &lt;code&gt;pg_isready&lt;/code&gt; passes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How we tested the HTTPS part
&lt;/h3&gt;

&lt;p&gt;A public certificate authority cannot reach a laptop, so we checked the production Caddyfile with &lt;code&gt;caddy validate&lt;/code&gt;, then ran the whole stack with one change: a &lt;code&gt;tls internal&lt;/code&gt; line inside each site block, which makes Caddy sign its own certificate. The site answered &lt;code&gt;200&lt;/code&gt; over HTTPS through Caddy, &lt;code&gt;https://www.example.com/pricing&lt;/code&gt; answered &lt;code&gt;301&lt;/code&gt; to &lt;code&gt;https://example.com/pricing&lt;/code&gt;, and PostgreSQL 18.6 answered queries. On the server you leave &lt;code&gt;tls internal&lt;/code&gt; out, and Caddy requests a real certificate from Let's Encrypt (ZeroSSL is its fallback) the first time it starts.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Push the image and start the stack on the server
&lt;/h2&gt;

&lt;p&gt;The server should run images, not build them: in our test &lt;code&gt;next build&lt;/code&gt; peaked at about 780 MB of memory, which on a 2 GB server competes with the app and the database. Build in CI (the &lt;a href="https://opscrew.dev/blog/deploy-docker-compose-to-hetzner/" rel="noopener noreferrer"&gt;GitHub Actions workflow for Hetzner&lt;/a&gt; works for any VPS) or, for the first deploy, from your computer.&lt;/p&gt;

&lt;p&gt;To push from your computer to GitHub Container Registry, log in with a personal access token (classic) that has the &lt;code&gt;write:packages&lt;/code&gt; scope, &lt;a href="https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry" rel="noopener noreferrer"&gt;as GitHub's documentation describes&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$CR_PAT"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; docker login ghcr.io -u YOUR_GITHUB_USERNAME --password-stdin
docker build -t ghcr.io/your-name/myapp:latest .
docker push ghcr.io/your-name/myapp:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;New packages are private, so on the server log in once with a token that has only &lt;code&gt;read:packages&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then, on the server (Docker installed as in the &lt;a href="https://opscrew.dev/blog/deploy-docker-compose-to-hetzner/" rel="noopener noreferrer"&gt;Hetzner&lt;/a&gt; or &lt;a href="https://opscrew.dev/blog/deploy-to-a-digitalocean-droplet/" rel="noopener noreferrer"&gt;DigitalOcean&lt;/a&gt; walk-through):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create an A record for &lt;code&gt;example.com&lt;/code&gt; (and &lt;code&gt;www&lt;/code&gt;) with the server's IP address, and wait until &lt;code&gt;dig +short example.com&lt;/code&gt; returns it.&lt;/li&gt;
&lt;li&gt;Make sure the provider's firewall allows TCP 80 and 443 (and UDP 443 for HTTP/3).&lt;/li&gt;
&lt;li&gt;In &lt;code&gt;/srv/myapp&lt;/code&gt;, run &lt;code&gt;docker compose up -d&lt;/code&gt;, then &lt;code&gt;docker compose logs -f caddy&lt;/code&gt; to watch Caddy obtain the certificate.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Open &lt;code&gt;https://example.com&lt;/code&gt;. If Caddy logs a certificate error, the DNS record or the firewall is almost always the cause.&lt;/p&gt;

&lt;h2&gt;
  
  
  The traps after you deploy Next.js to a VPS
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; variables are frozen at build time.&lt;/strong&gt; Next.js &lt;a href="https://nextjs.org/docs/app/guides/environment-variables" rel="noopener noreferrer"&gt;replaces each &lt;code&gt;process.env.NEXT_PUBLIC_*&lt;/code&gt; reference with its value&lt;/a&gt; during &lt;code&gt;next build&lt;/code&gt; and ships it in the browser bundle. Setting it in the server's &lt;code&gt;.env&lt;/code&gt; changes nothing for the browser. Pass it to the build instead, as a build argument read in the &lt;code&gt;builder&lt;/code&gt; stage, and never put a secret in it: everyone who loads the page can read it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server-side variables are read when the code runs.&lt;/strong&gt; Variables without the prefix stay on the server. In the App Router they are read at request time in dynamically rendered code (after &lt;code&gt;await connection()&lt;/code&gt;, &lt;code&gt;cookies()&lt;/code&gt; or &lt;code&gt;headers()&lt;/code&gt;); a page that Next.js prerendered at build time keeps the values it had then. If a page shows a stale value, it was prerendered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Two copies of the app need the same keys.&lt;/strong&gt; For &lt;a href="https://opscrew.dev/blog/zero-downtime-deployment-docker-compose/" rel="noopener noreferrer"&gt;zero-downtime updates&lt;/a&gt; you run two containers. &lt;a href="https://nextjs.org/docs/app/guides/self-hosting" rel="noopener noreferrer"&gt;The Next.js self-hosting guide warns&lt;/a&gt; that a Server Function encrypted by one instance cannot be decrypted by another unless they share &lt;code&gt;NEXT_SERVER_ACTIONS_ENCRYPTION_KEY&lt;/code&gt; (a base64 AES key set at build time), and it recommends a &lt;code&gt;deploymentId&lt;/code&gt; in &lt;code&gt;next.config.ts&lt;/code&gt;: when a browser holds the previous release, Next.js then does a full page reload instead of a client-side navigation, so the browser never mixes assets from two releases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caches are per container.&lt;/strong&gt; The default cache lives in each container's memory and disk. One container is fine; with several, the self-hosting guide describes a shared cache handler.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Images on glibc Linux.&lt;/strong&gt; The self-hosting guide says &lt;code&gt;next/image&lt;/code&gt; optimisation works with zero configuration under &lt;code&gt;next start&lt;/code&gt;, and notes that on glibc-based Linux (which &lt;code&gt;node:24-slim&lt;/code&gt; is) it may need extra configuration to prevent excessive memory use; watch the container's memory if your app serves many images.&lt;/p&gt;

&lt;h2&gt;
  
  
  Updating the app
&lt;/h2&gt;

&lt;p&gt;The simplest update: build and push a new image, set &lt;code&gt;APP_TAG&lt;/code&gt; to its tag in &lt;code&gt;.env&lt;/code&gt;, and run &lt;code&gt;docker compose up -d&lt;/code&gt;. Compose replaces the app container and leaves the database and Caddy alone. For a few seconds during the swap, requests fail. If that matters, run two copies of the app as shown in &lt;a href="https://opscrew.dev/blog/zero-downtime-deployment-docker-compose/" rel="noopener noreferrer"&gt;zero-downtime deployments with Docker Compose&lt;/a&gt;, which we tested under load with this same image.&lt;/p&gt;

&lt;h2&gt;
  
  
  Doing this with OpsCrew
&lt;/h2&gt;

&lt;p&gt;OpsCrew, the open-source tool we build, does these steps for a Next.js app with your approval at each one. It prepares the app for a container, chooses how to build its image (see &lt;a href="https://docs.opscrew.dev/builders/" rel="noopener noreferrer"&gt;how OpsCrew builds your app's image&lt;/a&gt;), runs PostgreSQL next to it with a generated password and no public port (&lt;a href="https://docs.opscrew.dev/databases/" rel="noopener noreferrer"&gt;databases&lt;/a&gt;), and puts Caddy in front with HTTPS (&lt;a href="https://docs.opscrew.dev/reverse-proxy/" rel="noopener noreferrer"&gt;the reverse proxy&lt;/a&gt;). Deploys run from a GitHub Actions workflow it opens as a pull request, and switch releases &lt;a href="https://docs.opscrew.dev/zero-downtime/" rel="noopener noreferrer"&gt;without downtime&lt;/a&gt;. When you leave Vercel, it also carries the routing rules from &lt;code&gt;vercel.json&lt;/code&gt; into the proxy's configuration; rules in &lt;code&gt;next.config.js&lt;/code&gt; need nothing, since Next.js applies them itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to go next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Automate the build and deploy: &lt;a href="https://opscrew.dev/blog/deploy-docker-compose-to-hetzner/" rel="noopener noreferrer"&gt;Deploy a Docker Compose app to Hetzner with GitHub Actions&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Remove the seconds of downtime: &lt;a href="https://opscrew.dev/blog/zero-downtime-deployment-docker-compose/" rel="noopener noreferrer"&gt;Zero-downtime deployments with Docker Compose&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;See every other part of running the server, from backups to hardening: &lt;a href="https://opscrew.dev/blog/deploy-web-app-to-a-vps/" rel="noopener noreferrer"&gt;How to deploy a web app to a VPS&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nextjs.org/docs/app/api-reference/config/next-config-js/output" rel="noopener noreferrer"&gt;Next.js docs: output (standalone)&lt;/a&gt;, Vercel (Next.js)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://nextjs.org/docs/app/guides/self-hosting" rel="noopener noreferrer"&gt;How to self-host your Next.js application&lt;/a&gt;, Vercel (Next.js)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://nextjs.org/docs/app/guides/environment-variables" rel="noopener noreferrer"&gt;Next.js docs: environment variables&lt;/a&gt;, Vercel (Next.js)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/vercel/next.js/tree/canary/examples/with-docker" rel="noopener noreferrer"&gt;Next.js example: with-docker (Dockerfile)&lt;/a&gt;, Vercel (Next.js repository)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://caddyserver.com/docs/automatic-https" rel="noopener noreferrer"&gt;Automatic HTTPS&lt;/a&gt;, Caddy&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://hub.docker.com/_/postgres" rel="noopener noreferrer"&gt;Postgres official image&lt;/a&gt;, Docker Hub&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry" rel="noopener noreferrer"&gt;Working with the Container registry&lt;/a&gt;, GitHub&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nextjs</category>
      <category>docker</category>
      <category>dockercompose</category>
      <category>caddy</category>
    </item>
    <item>
      <title>How to deploy an app you built with AI to your own server</title>
      <dc:creator>Mihailo Popović</dc:creator>
      <pubDate>Fri, 20 Nov 2026 17:29:27 +0000</pubDate>
      <link>https://dev.to/softzer0/how-to-deploy-an-app-you-built-with-ai-to-your-own-server-59l0</link>
      <guid>https://dev.to/softzer0/how-to-deploy-an-app-you-built-with-ai-to-your-own-server-59l0</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://opscrew.dev/blog/deploy-ai-built-app-to-your-own-server/" rel="noopener noreferrer"&gt;the OpsCrew blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Get the code into a GitHub repository, then find out whether it is static files (a Vite single-page app, which needs an &lt;code&gt;index.html&lt;/code&gt; fallback) or a server (Next.js, TanStack Start, Express) that needs Node.js running.&lt;/li&gt;
&lt;li&gt;Most builder apps keep their backend hosted (Supabase, Lovable Cloud, Bolt Database, Replit's database), so you can move only the frontend and keep it, or move both.&lt;/li&gt;
&lt;li&gt;Public variables such as &lt;code&gt;VITE_&lt;/code&gt; and &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; are baked in at build time, so set them before you build, and keep real secrets on the server only.&lt;/li&gt;
&lt;li&gt;Run the app in a container behind a reverse proxy such as Caddy, which gets and renews the HTTPS certificate by itself; before you switch the domain, check deep links, sign-in redirects and hardcoded preview URLs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To deploy an AI-built app to your own server, you do five things: get the code into a Git repository, find out whether it is static files or a server, decide where its backend lives, build it into a container image with the right environment variables, and run that image behind a reverse proxy that serves your domain over HTTPS. Lovable, Bolt.new, Replit, v0 and Claude Code all take this path; what differs is the stack each one produces and the backend it leans on.&lt;/p&gt;

&lt;p&gt;Every builder fact below comes from the builder's own documentation, checked on 11 November 2026. The Dockerfiles and the Caddy and Docker Compose files in the builder guides were built and run in Docker the same day, on Node.js 22, against fresh apps from the Vite, TanStack Start and Next.js starters and a small Express and PostgreSQL app.&lt;/p&gt;

&lt;h2&gt;
  
  
  When staying on the builder's hosting is the better choice
&lt;/h2&gt;

&lt;p&gt;Every builder hosts what it builds: Lovable publishes to &lt;code&gt;lovable.app&lt;/code&gt; with custom domains and a managed backend, Bolt has Bolt Cloud hosting with &lt;code&gt;.bolt.host&lt;/code&gt; addresses, &lt;a href="https://docs.replit.com/learn/projects-and-artifacts/replit-deployments" rel="noopener noreferrer"&gt;Replit publishes to its own Google Cloud infrastructure&lt;/a&gt;, and &lt;a href="https://v0.app/docs/faqs" rel="noopener noreferrer"&gt;v0 publishes to Vercel&lt;/a&gt;. &lt;a href="https://docs.lovable.dev/tips-tricks/deployment-hosting-ownership" rel="noopener noreferrer"&gt;Lovable's own docs recommend&lt;/a&gt; starting on Lovable, syncing the code with Git, and moving parts only when you hit a real constraint. Stay where you are when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you still build and change the app in the builder every day, and its one-click publish is part of that loop;&lt;/li&gt;
&lt;li&gt;the app is a prototype or an internal tool, and the builder's hosting costs less than your time;&lt;/li&gt;
&lt;li&gt;the app leans on services the builder runs for you and you do not want to replace them yet. Lovable's AI features and app connectors, for example, run through Lovable, and moving the built-in backend means replacing them with your own provider accounts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Move when you need something the builder's hosting does not give you: a fixed monthly price, data in a region or on hardware you choose, other services on the same machine, root access, or an app that no longer depends on one vendor. The comparisons of &lt;a href="https://opscrew.dev/compare/own-server-vs-vercel/" rel="noopener noreferrer"&gt;your own server against Vercel&lt;/a&gt; and &lt;a href="https://opscrew.dev/compare/own-server-vs-hosting-platform/" rel="noopener noreferrer"&gt;against hosting platforms in general&lt;/a&gt; go through the trade-offs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Get the code into a Git repository
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Builder&lt;/th&gt;
&lt;th&gt;Way out&lt;/th&gt;
&lt;th&gt;What to know&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Lovable&lt;/td&gt;
&lt;td&gt;Git sync with GitHub (github.com on every plan), GitLab or Bitbucket; a &lt;code&gt;.zip&lt;/code&gt; download on paid plans&lt;/td&gt;
&lt;td&gt;Sync creates a new private repository and syncs both ways, one branch at a time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bolt.new&lt;/td&gt;
&lt;td&gt;GitHub from the project's GitHub icon; Download from the project title menu&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://support.bolt.new/integrations/git" rel="noopener noreferrer"&gt;Bolt creates a private repository&lt;/a&gt; on &lt;code&gt;main&lt;/code&gt; and commits after each change&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Replit&lt;/td&gt;
&lt;td&gt;The Git pane (Tools, then Git), or &lt;code&gt;git push&lt;/code&gt; from the Shell&lt;/td&gt;
&lt;td&gt;Secrets and App Storage files do not travel with the code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v0&lt;/td&gt;
&lt;td&gt;Project menu, Settings, GitHub, Connect&lt;/td&gt;
&lt;td&gt;v0 creates a private repository and pushes to a working branch per chat&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude Code, Cursor&lt;/td&gt;
&lt;td&gt;&lt;a href="https://code.claude.com/docs/en/overview" rel="noopener noreferrer"&gt;The code is already on your computer&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Commit it and push it to a repository you own&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;How each builder gets its code to GitHub, checked 11 November 2026&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Then clone the repository and run the app on your own computer. If it does not start locally, it will not start on a server, and a local run shows you every environment variable it expects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Find out what kind of app it is
&lt;/h2&gt;

&lt;p&gt;Open &lt;code&gt;package.json&lt;/code&gt; and look at the dependencies and the &lt;code&gt;build&lt;/code&gt; and &lt;code&gt;start&lt;/code&gt; scripts.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What you find&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;What runs on the server&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;vite&lt;/code&gt; and &lt;code&gt;react&lt;/code&gt;, no server framework, a &lt;code&gt;build&lt;/code&gt; script that writes &lt;code&gt;dist/&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;A static single-page app (Lovable projects from before 13 May 2026, and any builder's Vite app)&lt;/td&gt;
&lt;td&gt;A web server that serves &lt;code&gt;dist/&lt;/code&gt; and answers unknown paths with &lt;code&gt;index.html&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;@tanstack/react-start&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A TanStack Start app (&lt;a href="https://docs.lovable.dev/features/upgrade-to-tanstack-start" rel="noopener noreferrer"&gt;Lovable projects since 13 May 2026&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;Node.js running &lt;code&gt;.output/server/index.mjs&lt;/code&gt;, port 3000 by default&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;next&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A Next.js app (every v0 project)&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://nextjs.org/docs/app/guides/self-hosting" rel="noopener noreferrer"&gt;Node.js running the Next.js server&lt;/a&gt;, port 3000 by default&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;express&lt;/code&gt;, &lt;code&gt;fastify&lt;/code&gt;, &lt;code&gt;hono&lt;/code&gt; or a &lt;code&gt;start&lt;/code&gt; script that runs &lt;code&gt;node&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;A Node.js server, sometimes serving a built frontend too&lt;/td&gt;
&lt;td&gt;Node.js running the start script, on the port in &lt;code&gt;PORT&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;The stacks AI builders produce and what each needs to run&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Decide where the backend lives
&lt;/h2&gt;

&lt;p&gt;Most builder apps keep their data and sign-in in a hosted service that the code reaches over the internet and that does not move with it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lovable Cloud&lt;/strong&gt; is Lovable's built-in backend, built on Supabase: a database, sign-in, file storage, edge functions and secrets. &lt;a href="https://docs.lovable.dev/tips-tricks/external-deployment-hosting" rel="noopener noreferrer"&gt;Lovable's docs describe hosting the frontend elsewhere&lt;/a&gt; while keeping it, and moving the backend only to managed or self-hosted Supabase.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supabase&lt;/strong&gt; that you connected yourself is your own project, reachable from any host.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bolt Database&lt;/strong&gt; is Bolt's built-in database. Bolt's documented way to own it is to claim it into your Supabase organisation, on the Pro or Teams plan.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replit's database&lt;/strong&gt; is a managed PostgreSQL with &lt;a href="https://docs.replit.com/cloud-services/storage-and-databases/production-databases" rel="noopener noreferrer"&gt;separate development and production databases&lt;/a&gt;. Only the production one is reachable from outside the app, through its connection string, which is how you copy the data out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;v0's integrations&lt;/strong&gt; (Neon, Supabase, Upstash, Vercel Blob) are added through the Vercel Marketplace, and their connection values live in the Vercel project's environment variables.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Move the frontend first and keep the backend where it is. Once the app runs on your server against it, decide whether to move the data too, as a separate step with its own test.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Sort the environment variables
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Build-time public variables.&lt;/strong&gt; &lt;a href="https://vite.dev/guide/env-and-mode" rel="noopener noreferrer"&gt;Vite exposes variables&lt;/a&gt; that start with &lt;code&gt;VITE_&lt;/code&gt; to the browser and replaces them in the code at build time; Next.js does the same with &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt;. Their values end up inside the JavaScript every visitor downloads, so:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;they must be set when the image is built, not only when it runs, or the app ships with empty values;&lt;/li&gt;
&lt;li&gt;changing one means building again;&lt;/li&gt;
&lt;li&gt;they must never hold a secret. A Supabase URL and its publishable (anon) key are meant to be public; a service role key, a Stripe secret key or a database password is not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Runtime variables.&lt;/strong&gt; Everything else, read on the server while the app runs: &lt;code&gt;DATABASE_URL&lt;/code&gt;, API secrets, session secrets. These go into the container's environment on the server, from a file that never enters the repository. A server-rendered app can need a public value twice: a Lovable TanStack Start app reads its Supabase URL and key as &lt;code&gt;VITE_&lt;/code&gt; values in the browser and again as &lt;code&gt;SUPABASE_URL&lt;/code&gt; and &lt;code&gt;SUPABASE_PUBLISHABLE_KEY&lt;/code&gt; on the server.&lt;/p&gt;

&lt;p&gt;Collect both lists before you build. Lovable keeps its public Supabase values in the repository's &lt;code&gt;.env&lt;/code&gt;; Bolt keeps environment variables in &lt;code&gt;.env&lt;/code&gt; but its secrets only on Bolt's servers; Replit's secrets must be re-entered; v0 keeps everything in the Vercel project's settings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Put the app in a container
&lt;/h2&gt;

&lt;p&gt;The Dockerfile depends on the stack from step 2; each builder article has one that was built and run for that stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a static Vite app: build with Node.js, then serve &lt;code&gt;dist/&lt;/code&gt; with Caddy and an &lt;code&gt;index.html&lt;/code&gt; fallback (in &lt;a href="https://opscrew.dev/blog/deploy-lovable-app-to-your-own-server/" rel="noopener noreferrer"&gt;the Lovable guide&lt;/a&gt; and &lt;a href="https://opscrew.dev/blog/deploy-bolt-new-app/" rel="noopener noreferrer"&gt;the Bolt.new guide&lt;/a&gt;);&lt;/li&gt;
&lt;li&gt;a TanStack Start app: build with Nitro's Node.js preset and run &lt;code&gt;node .output/server/index.mjs&lt;/code&gt; (&lt;a href="https://opscrew.dev/blog/deploy-lovable-app-to-your-own-server/" rel="noopener noreferrer"&gt;the Lovable guide&lt;/a&gt;);&lt;/li&gt;
&lt;li&gt;a Next.js app: build with &lt;code&gt;output: "standalone"&lt;/code&gt; and run &lt;code&gt;node server.js&lt;/code&gt; (&lt;a href="https://opscrew.dev/blog/deploy-v0-app-without-vercel/" rel="noopener noreferrer"&gt;the v0 guide&lt;/a&gt;, and &lt;a href="https://opscrew.dev/blog/deploy-nextjs-to-a-vps/" rel="noopener noreferrer"&gt;Next.js on a VPS&lt;/a&gt; for more depth);&lt;/li&gt;
&lt;li&gt;a Node.js server with a PostgreSQL database next to it (&lt;a href="https://opscrew.dev/blog/deploy-replit-app-to-a-vps/" rel="noopener noreferrer"&gt;the Replit guide&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every stack gets the same front door: a reverse proxy takes the public traffic on ports 80 and 443 and passes requests to the app. Caddy also &lt;a href="https://caddyserver.com/docs/automatic-https" rel="noopener noreferrer"&gt;handles the domain's HTTPS certificate by itself&lt;/a&gt;: when the domain's DNS record points at the server and ports 80 and 443 are open, it obtains and renews it and redirects HTTP to HTTPS. This &lt;code&gt;Caddyfile&lt;/code&gt; is the whole configuration for an app that listens on port 3000:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.example.com {
    reverse_proxy app:3000
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This &lt;code&gt;compose.yaml&lt;/code&gt; runs the app and Caddy together, with the certificate kept in a volume so it survives restarts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.&lt;/span&gt;
    &lt;span class="na"&gt;env_file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.env.production&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;

  &lt;span class="na"&gt;caddy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;caddy:2-alpine&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"80:80"&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"443:443"&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"443:443/udp"&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./Caddyfile:/etc/caddy/Caddyfile:ro&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;caddy_data:/data&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;caddy_config:/config&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;caddy_data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;caddy_config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;app.example.com&lt;/code&gt; with your domain; on the server, &lt;code&gt;docker compose up -d --build&lt;/code&gt; builds the image and starts both. Build-time variables from step 4 go under &lt;code&gt;build.args&lt;/code&gt;, as each builder guide shows. Only Caddy's ports are published to the internet, never the app's. We ran these files with &lt;code&gt;localhost&lt;/code&gt; as the site address, where Caddy issues a certificate from its own local authority; a public certificate for a real domain needs a real server and DNS record, which this test did not cover.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Get a server and point the domain at it
&lt;/h2&gt;

&lt;p&gt;Any Linux server with Docker works, including one you already pay for. The general steps are the same for every app: &lt;a href="https://opscrew.dev/blog/deploy-web-app-to-a-vps/" rel="noopener noreferrer"&gt;how to deploy a web app to a VPS&lt;/a&gt; covers creating the server, SSH keys, the firewall and Docker; &lt;a href="https://opscrew.dev/blog/deploy-docker-compose-to-hetzner/" rel="noopener noreferrer"&gt;Docker Compose on Hetzner with GitHub Actions&lt;/a&gt; and &lt;a href="https://opscrew.dev/blog/deploy-to-a-digitalocean-droplet/" rel="noopener noreferrer"&gt;a DigitalOcean Droplet&lt;/a&gt; walk through two providers; and &lt;a href="https://opscrew.dev/blog/hetzner-vs-digitalocean/" rel="noopener noreferrer"&gt;Hetzner vs DigitalOcean&lt;/a&gt; helps you pick one.&lt;/p&gt;

&lt;p&gt;For the domain, add an A record (and an AAAA record if the server has IPv6) pointing at the server's address. Caddy can only get the certificate after that record resolves, so set it before the first start.&lt;/p&gt;

&lt;p&gt;Once the app is live, add &lt;a href="https://opscrew.dev/blog/zero-downtime-deployment-docker-compose/" rel="noopener noreferrer"&gt;deploys without downtime&lt;/a&gt;, so an update does not drop visitors, and &lt;a href="https://opscrew.dev/blog/preview-environments-on-your-own-server/" rel="noopener noreferrer"&gt;a preview for every pull request&lt;/a&gt;, which replaces the builder's preview link.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: Fix what breaks after the move
&lt;/h2&gt;

&lt;p&gt;Check each of these on a temporary address while the builder's hosting keeps running. Once all pass, move the domain and unpublish the old copy when you are ready.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symptom&lt;/th&gt;
&lt;th&gt;Cause&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The app loads but data calls fail, or a value shows as &lt;code&gt;undefined&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;A &lt;code&gt;VITE_&lt;/code&gt; or &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; variable was not set at build time&lt;/td&gt;
&lt;td&gt;Pass it as a build argument and build again&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Refreshing &lt;code&gt;/dashboard&lt;/code&gt; gives a 404&lt;/td&gt;
&lt;td&gt;A static single-page app with no fallback to &lt;code&gt;index.html&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Add the fallback (&lt;code&gt;try_files {path} /index.html&lt;/code&gt; in Caddy)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sign-in fails or sends users back to the old address&lt;/td&gt;
&lt;td&gt;The new domain is not in the auth provider's redirect allow list&lt;/td&gt;
&lt;td&gt;Add it to Supabase's Site URL and Redirect URLs, and to each OAuth provider&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Links, emails or API calls point at &lt;code&gt;lovable.app&lt;/code&gt;, &lt;code&gt;.bolt.host&lt;/code&gt;, &lt;code&gt;.replit.app&lt;/code&gt; or &lt;code&gt;vercel.app&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;A preview URL hardcoded in the code or in a variable&lt;/td&gt;
&lt;td&gt;Search the repository for the old host and replace it with a variable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The server returns 502&lt;/td&gt;
&lt;td&gt;The app listens on &lt;code&gt;localhost&lt;/code&gt; or a fixed port&lt;/td&gt;
&lt;td&gt;Listen on &lt;code&gt;0.0.0.0&lt;/code&gt; and on the port in &lt;code&gt;PORT&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Uploaded files disappear&lt;/td&gt;
&lt;td&gt;The app writes files into the container&lt;/td&gt;
&lt;td&gt;Use object storage or a mounted volume&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;What breaks after you move an AI-built app, and why&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Lovable apps, and Bolt apps whose database you claimed into Supabase, sign users in through Supabase. &lt;a href="https://supabase.com/docs/guides/auth/redirect-urls" rel="noopener noreferrer"&gt;Its Site URL is the default redirect address&lt;/a&gt; that confirmation and password-reset emails use, and its Redirect URLs list says where users may be sent after sign-in. In a Supabase project of your own, both are on the dashboard's URL Configuration page; for Lovable Cloud, Lovable's hosting guide says only to add the new address to the auth provider's allowed redirect URLs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy an AI-built app, builder by builder
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lovable.&lt;/strong&gt; &lt;a href="https://opscrew.dev/blog/deploy-lovable-app-to-your-own-server/" rel="noopener noreferrer"&gt;Deploy a Lovable app to your own server&lt;/a&gt; covers both the Vite and the TanStack Start path, and the backend that is Supabase underneath.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replit.&lt;/strong&gt; &lt;a href="https://opscrew.dev/blog/deploy-replit-app-to-a-vps/" rel="noopener noreferrer"&gt;Deploy a Replit app to a VPS&lt;/a&gt; translates the four deployment types and the &lt;code&gt;.replit&lt;/code&gt; build and run commands, and copies the production database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bolt.new.&lt;/strong&gt; &lt;a href="https://opscrew.dev/blog/deploy-bolt-new-app/" rel="noopener noreferrer"&gt;Deploy a Bolt.new app to your own server&lt;/a&gt; gets the code out and claims Bolt Database into Supabase.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;v0.&lt;/strong&gt; &lt;a href="https://opscrew.dev/blog/deploy-v0-app-without-vercel/" rel="noopener noreferrer"&gt;Deploy a v0 app without Vercel&lt;/a&gt; moves it to a standalone Next.js server and gets its environment variables out of Vercel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Claude Code and Cursor.&lt;/strong&gt; The code is already yours; &lt;a href="https://opscrew.dev/blog/deploy-claude-code-app/" rel="noopener noreferrer"&gt;Claude Code built your app: here is how to put it online&lt;/a&gt; covers where it runs and how much of the deploy you let an agent do.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Doing this with OpsCrew
&lt;/h2&gt;

&lt;p&gt;OpsCrew is an open-source tool that takes an app from its GitHub repository to a hardened server on your own cloud account. It recognises code exported from Lovable, Bolt, Replit and v0, and its free &lt;code&gt;opscrew scan&lt;/code&gt; checks the repository for leaked keys and exposed Supabase or Firebase data before you go live.&lt;/p&gt;

&lt;p&gt;It &lt;a href="https://docs.opscrew.dev/builders/" rel="noopener noreferrer"&gt;builds the container image&lt;/a&gt; in GitHub Actions with its own Dockerfile for Vite and Next.js apps and Node.js servers such as Express (or yours, if the repository has one), and handles &lt;code&gt;VITE_&lt;/code&gt; and &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; values as &lt;a href="https://docs.opscrew.dev/builders/#values-the-build-needs" rel="noopener noreferrer"&gt;build-time values&lt;/a&gt; that are public by nature. It deploys to a new server on Hetzner Cloud or DigitalOcean, or to &lt;a href="https://docs.opscrew.dev/own-server/" rel="noopener noreferrer"&gt;a server you already have&lt;/a&gt;, &lt;a href="https://docs.opscrew.dev/domains/" rel="noopener noreferrer"&gt;buys or connects your domain&lt;/a&gt; on Cloudflare, and runs &lt;a href="https://docs.opscrew.dev/databases/" rel="noopener noreferrer"&gt;a database next to your app&lt;/a&gt; when you want one, or keeps the hosted one you already use. Every change waits for your approval of its exact plan. In Claude Code, the &lt;a href="https://docs.opscrew.dev/claude-code-plugin/" rel="noopener noreferrer"&gt;OpsCrew plugin&lt;/a&gt; runs the same flow from the chat. The &lt;a href="https://opscrew.dev/setup/" rel="noopener noreferrer"&gt;setup page&lt;/a&gt; lists the accounts and tools you need, and &lt;a href="https://opscrew.dev/use-cases/" rel="noopener noreferrer"&gt;use cases&lt;/a&gt; shows what it does for an app from an AI builder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.lovable.dev/tips-tricks/external-deployment-hosting" rel="noopener noreferrer"&gt;Deploying and hosting outside Lovable&lt;/a&gt;, Lovable&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.lovable.dev/tips-tricks/deployment-hosting-ownership" rel="noopener noreferrer"&gt;Deployment, hosting, and ownership options with Lovable&lt;/a&gt;, Lovable&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.lovable.dev/features/upgrade-to-tanstack-start" rel="noopener noreferrer"&gt;Upgrade a project to TanStack Start&lt;/a&gt;, Lovable&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://support.bolt.new/integrations/git" rel="noopener noreferrer"&gt;GitHub for version control&lt;/a&gt;, Bolt&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://support.bolt.new/reference/supported-technologies" rel="noopener noreferrer"&gt;Supported technologies&lt;/a&gt;, Bolt&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.replit.com/learn/projects-and-artifacts/replit-deployments" rel="noopener noreferrer"&gt;Publishing&lt;/a&gt;, Replit&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.replit.com/cloud-services/storage-and-databases/production-databases" rel="noopener noreferrer"&gt;Development and production databases&lt;/a&gt;, Replit&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://v0.app/docs/faqs" rel="noopener noreferrer"&gt;v0 FAQs&lt;/a&gt;, Vercel&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://code.claude.com/docs/en/overview" rel="noopener noreferrer"&gt;Claude Code overview&lt;/a&gt;, Anthropic&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://vite.dev/guide/env-and-mode" rel="noopener noreferrer"&gt;Env variables and modes&lt;/a&gt;, Vite&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://nextjs.org/docs/app/guides/self-hosting" rel="noopener noreferrer"&gt;How to self-host your Next.js application&lt;/a&gt;, Vercel&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://caddyserver.com/docs/automatic-https" rel="noopener noreferrer"&gt;Automatic HTTPS&lt;/a&gt;, Caddy&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://supabase.com/docs/guides/auth/redirect-urls" rel="noopener noreferrer"&gt;Redirect URLs&lt;/a&gt;, Supabase&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>lovable</category>
      <category>bolt</category>
      <category>replit</category>
      <category>v0</category>
    </item>
    <item>
      <title>Deploy a Lovable app to your own server (Vite or TanStack Start)</title>
      <dc:creator>Mihailo Popović</dc:creator>
      <pubDate>Thu, 12 Nov 2026 12:30:30 +0000</pubDate>
      <link>https://dev.to/softzer0/deploy-a-lovable-app-to-your-own-server-vite-or-tanstack-start-o25</link>
      <guid>https://dev.to/softzer0/deploy-a-lovable-app-to-your-own-server-vite-or-tanstack-start-o25</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://opscrew.dev/blog/deploy-lovable-app-to-your-own-server/" rel="noopener noreferrer"&gt;the OpsCrew blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lovable projects created on or after 13 May 2026 are TanStack Start apps that need a running Node.js server. Older ones are React and Vite apps that build to static files.&lt;/li&gt;
&lt;li&gt;Check package.json. If it lists &lt;code&gt;@tanstack/react-start&lt;/code&gt;, you have the server version.&lt;/li&gt;
&lt;li&gt;Connect GitHub in Lovable's Git settings, on any plan. Lovable creates a private repository and keeps it in sync both ways.&lt;/li&gt;
&lt;li&gt;Build a Vite app into dist/ and serve it with an index.html fallback. Build a TanStack Start app with &lt;code&gt;NITRO_PRESET=node-server&lt;/code&gt; and run node .output/server/index.mjs.&lt;/li&gt;
&lt;li&gt;Set &lt;code&gt;VITE_SUPABASE_URL&lt;/code&gt; and &lt;code&gt;VITE_SUPABASE_PUBLISHABLE_KEY&lt;/code&gt; before the build, because they are compiled into the JavaScript. A TanStack Start app's server also reads &lt;code&gt;SUPABASE_URL&lt;/code&gt; and &lt;code&gt;SUPABASE_PUBLISHABLE_KEY&lt;/code&gt; where it runs.&lt;/li&gt;
&lt;li&gt;The backend can stay on Lovable Cloud. Add the new domain to its sign-in redirect URLs before you switch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To deploy a Lovable app to your own server, sync it to GitHub, check which of Lovable's two stacks it uses, and build it accordingly: a React and Vite project becomes static files that any web server can serve, and a TanStack Start project becomes a Node.js server that has to keep running. Put either behind a reverse proxy with HTTPS, set the Supabase values before the build, and add the new domain to the sign-in redirect URLs. This guide does each step for both stacks. It is part of &lt;a href="https://opscrew.dev/blog/deploy-ai-built-app-to-your-own-server/" rel="noopener noreferrer"&gt;the guide to deploying an AI-built app to your own server&lt;/a&gt;, which covers what is common to every builder.&lt;/p&gt;

&lt;p&gt;The Lovable facts here come from Lovable's documentation, checked on 11 November 2026. The Dockerfiles were built and run that day on Node.js 22, against a fresh Vite app from &lt;code&gt;npm create vite@latest&lt;/code&gt; (Vite 8, React template) and a fresh TanStack Start app from the TanStack CLI with its Nitro deployment option.&lt;/p&gt;

&lt;h2&gt;
  
  
  First: which Lovable app do you have?
&lt;/h2&gt;

&lt;p&gt;Lovable changed its default stack in 2026, and the two need different hosting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TanStack Start&lt;/strong&gt;, the default for new projects since 13 May 2026 (and for new Enterprise projects since 22 June 2026). It renders pages into HTML on the server, and has server functions and API routes. It needs a host that runs Node.js; a static file host alone will not work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React and Vite&lt;/strong&gt;, every older project unless you upgraded it. It builds to static files in &lt;code&gt;dist/&lt;/code&gt; and routes in the browser, so any web server can host it, provided it answers unknown paths with &lt;code&gt;index.html&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To check, open &lt;code&gt;package.json&lt;/code&gt; in Lovable's Code tab or in your repository. If &lt;code&gt;@tanstack/react-start&lt;/code&gt; is in the dependencies, it is a TanStack Start app. Upgrading an older project is optional: Lovable keeps Vite projects working.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Sync the code to GitHub
&lt;/h2&gt;

&lt;p&gt;Git sync works on every Lovable plan with github.com. Only a workspace owner or admin can add the connection:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Workspace settings&lt;/strong&gt;, then &lt;strong&gt;Git&lt;/strong&gt;, then &lt;strong&gt;GitHub&lt;/strong&gt;, and choose &lt;strong&gt;Add connection&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Pick the account or organisation, choose which repositories the app may see, and click &lt;strong&gt;Install &amp;amp; Authorize&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In the project's Git settings, click &lt;strong&gt;Connect&lt;/strong&gt;. Lovable creates a new private repository and starts syncing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The sync goes both ways: changes in Lovable are pushed to the repository, and commits pushed to the synced branch (by default &lt;code&gt;main&lt;/code&gt;) come back into Lovable. You can keep building in Lovable after you move the hosting. Lovable always creates a new repository; it cannot connect to one that already exists. On a paid plan you can instead download a one-time &lt;code&gt;.zip&lt;/code&gt; snapshot.&lt;/p&gt;

&lt;p&gt;Neither route includes your database rows or uploaded files. Those live in the backend, which step 5 deals with.&lt;/p&gt;

&lt;p&gt;Clone the repository and run the app locally before you write a Dockerfile. Lovable's docs note that their npm examples assume a &lt;code&gt;package-lock.json&lt;/code&gt;: if the repository has only &lt;code&gt;bun.lock&lt;/code&gt;, either use Bun or run &lt;code&gt;npm install&lt;/code&gt; once and commit the &lt;code&gt;package-lock.json&lt;/code&gt; it writes. The Dockerfiles below use &lt;code&gt;npm ci&lt;/code&gt;, which needs that file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Collect the build-time values
&lt;/h2&gt;

&lt;p&gt;A Lovable app on the built-in backend reads three values from the &lt;code&gt;.env&lt;/code&gt; file in the repository:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;VITE_SUPABASE_URL&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;VITE_SUPABASE_PUBLISHABLE_KEY&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;VITE_SUPABASE_PROJECT_ID&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vite exposes any variable that starts with &lt;code&gt;VITE_&lt;/code&gt; to the browser and replaces it in the code at build time. That has two consequences. These values have to be present when the image is built, or the app ships without them and cannot reach its data. And anything in a &lt;code&gt;VITE_&lt;/code&gt; variable is readable by every visitor, which is fine for the Supabase URL and publishable key (they are meant to be public, and Row Level Security is what protects the data) and never fine for a secret.&lt;/p&gt;

&lt;p&gt;The Dockerfiles below take the values as build arguments and keep &lt;code&gt;.env&lt;/code&gt; out of the image, so what goes into a build is always explicit. Vite gives variables that are already set in the environment priority over &lt;code&gt;.env&lt;/code&gt; files, so the build arguments win either way.&lt;/p&gt;

&lt;p&gt;A TanStack Start app needs the same values a second time. Lovable's hosting guide says its server code also reads &lt;code&gt;SUPABASE_URL&lt;/code&gt; and &lt;code&gt;SUPABASE_PUBLISHABLE_KEY&lt;/code&gt; (and &lt;code&gt;SUPABASE_PROJECT_ID&lt;/code&gt;), set to the same values as the browser ones, as environment variables where the server runs. The &lt;code&gt;compose.yaml&lt;/code&gt; in step 4 passes them to the container.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3a: The Dockerfile for a Vite Lovable app
&lt;/h2&gt;

&lt;p&gt;This builds the app with Node.js 22, then copies only &lt;code&gt;dist/&lt;/code&gt; into a small Caddy image that serves the files on port 8080:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# Build stage: Node 22 builds the static files into dist/&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; node:22-alpine AS build
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;COPY&lt;/span&gt; package.json package-lock.json ./
&lt;span class="k"&gt;RUN&lt;/span&gt; npm ci
&lt;span class="k"&gt;COPY&lt;/span&gt; . .
&lt;span class="c"&gt;# VITE_ variables are compiled into the JavaScript at build time&lt;/span&gt;
&lt;span class="k"&gt;ARG&lt;/span&gt; VITE_SUPABASE_URL
&lt;span class="k"&gt;ARG&lt;/span&gt; VITE_SUPABASE_PUBLISHABLE_KEY
&lt;span class="k"&gt;ARG&lt;/span&gt; VITE_SUPABASE_PROJECT_ID
&lt;span class="k"&gt;RUN&lt;/span&gt; npm run build

&lt;span class="c"&gt;# Run stage: Caddy serves dist/ and sends unknown paths to index.html&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; caddy:2-alpine
&lt;span class="k"&gt;COPY&lt;/span&gt; spa.Caddyfile /etc/caddy/Caddyfile
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=build /app/dist /srv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;spa.Caddyfile&lt;/code&gt; next to it is what makes client-side routes work. Without &lt;code&gt;try_files&lt;/code&gt;, refreshing &lt;code&gt;/dashboard&lt;/code&gt; asks the server for a file called &lt;code&gt;dashboard&lt;/code&gt;, which does not exist, and the visitor gets a 404:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:8080 {
    root * /srv
    encode
    try_files {path} /index.html
    file_server
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add a &lt;code&gt;.dockerignore&lt;/code&gt; so local builds, Git history and your &lt;code&gt;.env&lt;/code&gt; stay out of the image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node_modules
dist
.git
.env
.env.*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our test, a request for &lt;code&gt;/dashboard/settings&lt;/code&gt; returned the app's &lt;code&gt;index.html&lt;/code&gt; with status 200, and the Supabase URL passed as a build argument appeared in the built JavaScript while the value in a local &lt;code&gt;.env&lt;/code&gt; did not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3b: The Dockerfile for a TanStack Start Lovable app
&lt;/h2&gt;

&lt;p&gt;A TanStack Start app is built by Nitro, which has a preset per platform. For a container you want the Node.js server preset, and the result is a self-contained server in &lt;code&gt;.output/&lt;/code&gt;. First check that &lt;code&gt;package.json&lt;/code&gt; lists &lt;code&gt;nitro&lt;/code&gt;. If it does not, follow TanStack's hosting guide: install it with &lt;code&gt;npm install nitro&lt;/code&gt; and add &lt;code&gt;nitro()&lt;/code&gt; from &lt;code&gt;nitro/vite&lt;/code&gt; to the plugins in &lt;code&gt;vite.config.ts&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt; node:22-alpine AS build
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;COPY&lt;/span&gt; package.json package-lock.json ./
&lt;span class="k"&gt;RUN&lt;/span&gt; npm ci
&lt;span class="k"&gt;COPY&lt;/span&gt; . .
&lt;span class="c"&gt;# Browser values are embedded at build time&lt;/span&gt;
&lt;span class="k"&gt;ARG&lt;/span&gt; VITE_SUPABASE_URL
&lt;span class="k"&gt;ARG&lt;/span&gt; VITE_SUPABASE_PUBLISHABLE_KEY
&lt;span class="k"&gt;ARG&lt;/span&gt; VITE_SUPABASE_PROJECT_ID
&lt;span class="k"&gt;ENV&lt;/span&gt; &lt;span class="nv"&gt;NITRO_PRESET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;node-server
&lt;span class="k"&gt;RUN&lt;/span&gt; npm run build

&lt;span class="k"&gt;FROM&lt;/span&gt; node:22-alpine
&lt;span class="k"&gt;WORKDIR&lt;/span&gt; /app
&lt;span class="k"&gt;ENV&lt;/span&gt; &lt;span class="nv"&gt;NODE_ENV&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production &lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3000 &lt;span class="nv"&gt;HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.0.0.0
&lt;span class="k"&gt;COPY&lt;/span&gt; --from=build --chown=node:node /app/.output ./.output
&lt;span class="k"&gt;USER&lt;/span&gt; node
&lt;span class="k"&gt;EXPOSE&lt;/span&gt; 3000
&lt;span class="k"&gt;CMD&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;, &lt;span class="s2"&gt;".output/server/index.mjs"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The run stage copies only &lt;code&gt;.output/&lt;/code&gt;, because Nitro bundles the server and the dependencies it needs into it. The server listens on port 3000, set by &lt;code&gt;PORT&lt;/code&gt; and &lt;code&gt;HOST&lt;/code&gt;. Do not add a &lt;code&gt;try_files&lt;/code&gt; fallback in front of it: the server handles routing itself. Server-only secrets (an API key a server function uses, for example) go into the container's environment at run time, not into build arguments.&lt;/p&gt;

&lt;p&gt;Use the same &lt;code&gt;.dockerignore&lt;/code&gt; as above, with &lt;code&gt;.output&lt;/code&gt; added. The Supabase values the server reads at run time come from &lt;code&gt;compose.yaml&lt;/code&gt;, in the next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Run it behind Caddy on your server
&lt;/h2&gt;

&lt;p&gt;Both stacks sit behind the same reverse proxy, which takes ports 80 and 443, gets a certificate for your domain and forwards requests to the app. The &lt;code&gt;Caddyfile&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.example.com {
    reverse_proxy app:8080
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;app:8080&lt;/code&gt; for the Vite image above and &lt;code&gt;app:3000&lt;/code&gt; for TanStack Start. Then a &lt;code&gt;compose.yaml&lt;/code&gt; that builds the app with its build arguments and runs Caddy beside it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.&lt;/span&gt;
      &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;VITE_SUPABASE_URL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${VITE_SUPABASE_URL}&lt;/span&gt;
        &lt;span class="na"&gt;VITE_SUPABASE_PUBLISHABLE_KEY&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${VITE_SUPABASE_PUBLISHABLE_KEY}&lt;/span&gt;
        &lt;span class="na"&gt;VITE_SUPABASE_PROJECT_ID&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${VITE_SUPABASE_PROJECT_ID}&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="c1"&gt;# Read at run time by TanStack Start's server code; the Vite image ignores them
&lt;/span&gt;      &lt;span class="na"&gt;SUPABASE_URL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${VITE_SUPABASE_URL}&lt;/span&gt;
      &lt;span class="na"&gt;SUPABASE_PUBLISHABLE_KEY&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${VITE_SUPABASE_PUBLISHABLE_KEY}&lt;/span&gt;
      &lt;span class="na"&gt;SUPABASE_PROJECT_ID&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${VITE_SUPABASE_PROJECT_ID}&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;

  &lt;span class="na"&gt;caddy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;caddy:2-alpine&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"80:80"&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"443:443"&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"443:443/udp"&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./Caddyfile:/etc/caddy/Caddyfile:ro&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;caddy_data:/data&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;caddy_config:/config&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;caddy_data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;caddy_config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;app.example.com&lt;/code&gt; with your domain. Docker Compose reads a &lt;code&gt;.env&lt;/code&gt; file next to &lt;code&gt;compose.yaml&lt;/code&gt; for the &lt;code&gt;${...}&lt;/code&gt; substitutions, which fill both the build arguments and the server's run-time variables, and Lovable keeps the three values in &lt;code&gt;.env&lt;/code&gt; at the project root, so a clone of the repository usually has them already; if yours does not, create the file on the server. The &lt;code&gt;.dockerignore&lt;/code&gt; keeps the file itself out of the image: the values reach the build only as the arguments listed. Point your domain's A record at the server and start it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose up -d --build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Caddy gets the certificate as soon as the domain resolves to the server and ports 80 and 443 are open. We ran this stack with &lt;code&gt;localhost&lt;/code&gt; as the site address, where Caddy uses its own local certificate authority; HTTP was redirected to HTTPS and both stacks answered through the proxy. A public certificate for a real domain needs a real server, which the test did not use.&lt;/p&gt;

&lt;p&gt;If you do not have a server yet, &lt;a href="https://opscrew.dev/blog/deploy-web-app-to-a-vps/" rel="noopener noreferrer"&gt;deploying a web app to a VPS&lt;/a&gt; covers creating one, SSH keys, the firewall and Docker, and &lt;a href="https://opscrew.dev/blog/hetzner-vs-digitalocean/" rel="noopener noreferrer"&gt;Hetzner vs DigitalOcean&lt;/a&gt; helps you choose a provider.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Keep the backend, or move it
&lt;/h2&gt;

&lt;p&gt;Lovable Cloud, the built-in backend, is built on Supabase: database, sign-in, storage, realtime, edge functions and secrets. You have three options for it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep Lovable Cloud (the simplest move).&lt;/strong&gt; Lovable documents hosting the frontend elsewhere while keeping the built-in backend, and you can go on building in Lovable, with its AI features and app connectors still working. You set the new host's environment variables and server secrets, and add the new domain to the sign-in redirect URLs. In Supabase terms, that is the Site URL (the default redirect address that confirmation and password-reset emails use) and the list of allowed Redirect URLs; any Google or GitHub sign-in also needs the new address in that provider's OAuth settings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Move to your own Supabase project.&lt;/strong&gt; This is the reference path in Lovable's docs. In short: create the project, apply the migrations in &lt;code&gt;supabase/migrations/&lt;/code&gt; in order, restore the data export (it includes user accounts and password hashes, so users keep their passwords but must sign in again), reconfigure the sign-in providers and redirect URLs, copy the storage files, set the secrets, deploy the edge functions, recreate scheduled jobs, test on a separate deployment, and only then switch the values in &lt;code&gt;.env&lt;/code&gt; and &lt;code&gt;supabase/config.toml&lt;/code&gt;. Lovable's full export is a PostgreSQL custom-format archive with zstd compression, restored with &lt;code&gt;pg_restore&lt;/code&gt;, and you can request one every 24 hours. Calls to Lovable's AI features and app connectors keep running through Lovable until you replace them with your own provider accounts, so plan that replacement as part of the move.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self-host Supabase.&lt;/strong&gt; For data residency or full control, Lovable points to Supabase's own Docker self-hosting guide. A plain PostgreSQL database is not enough: the app needs Supabase's auth, storage, realtime and edge services too.&lt;/p&gt;

&lt;p&gt;Move the frontend first. Once the app runs on your server against the backend it already has, moving the backend is a separate project with its own test run.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Test, then switch the domain
&lt;/h2&gt;

&lt;p&gt;Lovable's own checklist is the right one. On a temporary address:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Refresh a nested route. A 404 means a missing fallback (Vite) or a missing server (TanStack Start).&lt;/li&gt;
&lt;li&gt;Sign in and out. A redirect error means the address is not in the allow list.&lt;/li&gt;
&lt;li&gt;Read, write and upload something.&lt;/li&gt;
&lt;li&gt;For TanStack Start, load a server-rendered page and call a server function.&lt;/li&gt;
&lt;li&gt;Search the code for the old &lt;code&gt;lovable.app&lt;/code&gt; address, hardcoded in links, emails or callbacks.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Then point your custom domain at the server. The &lt;code&gt;lovable.app&lt;/code&gt; address keeps serving your last Lovable publish until you unpublish it, which gives you a fallback while DNS settles. Exporting code and moving the domain do not cancel your Lovable plan or Cloud usage; change those yourself when you are done.&lt;/p&gt;

&lt;p&gt;Two other guides in this series cover the same ground for similar apps: &lt;a href="https://opscrew.dev/blog/deploy-bolt-new-app/" rel="noopener noreferrer"&gt;a Bolt.new app&lt;/a&gt;, whose database is Bolt Database or your own Supabase project, and &lt;a href="https://opscrew.dev/blog/deploy-v0-app-without-vercel/" rel="noopener noreferrer"&gt;a v0 app&lt;/a&gt;, which is always Next.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  Doing this with OpsCrew
&lt;/h2&gt;

&lt;p&gt;OpsCrew recognises a repository exported from Lovable, and its free &lt;code&gt;opscrew scan&lt;/code&gt; checks it before it goes live for leaked keys and exposed Supabase data, such as a table without Row Level Security. It then &lt;a href="https://docs.opscrew.dev/builders/" rel="noopener noreferrer"&gt;builds the image&lt;/a&gt; in GitHub Actions, with its own Dockerfile for a Vite app or with yours when the repository has one (such as the TanStack Start Dockerfile above), treats &lt;code&gt;VITE_&lt;/code&gt; values as &lt;a href="https://docs.opscrew.dev/builders/#values-the-build-needs" rel="noopener noreferrer"&gt;public build-time values&lt;/a&gt;, and deploys to a new server on Hetzner Cloud or DigitalOcean or to &lt;a href="https://docs.opscrew.dev/own-server/" rel="noopener noreferrer"&gt;one you already have&lt;/a&gt;, with HTTPS on &lt;a href="https://docs.opscrew.dev/domains/" rel="noopener noreferrer"&gt;your domain&lt;/a&gt;. A static Vite app can also go on &lt;a href="https://docs.opscrew.dev/cloudflare-hosting/" rel="noopener noreferrer"&gt;Cloudflare's hosting with no server&lt;/a&gt;. Each change waits for your approval of its plan. &lt;a href="https://opscrew.dev/use-cases/" rel="noopener noreferrer"&gt;Use cases&lt;/a&gt; shows a scan of a test app shaped like a Lovable export.&lt;/p&gt;

&lt;p&gt;For everything that is the same across builders, go back to &lt;a href="https://opscrew.dev/blog/deploy-ai-built-app-to-your-own-server/" rel="noopener noreferrer"&gt;the guide to deploying an AI-built app to your own server&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.lovable.dev/tips-tricks/external-deployment-hosting" rel="noopener noreferrer"&gt;Deploying and hosting outside Lovable&lt;/a&gt;, Lovable&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.lovable.dev/tips-tricks/deployment-hosting-ownership" rel="noopener noreferrer"&gt;Deployment, hosting, and ownership options with Lovable&lt;/a&gt;, Lovable&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.lovable.dev/features/upgrade-to-tanstack-start" rel="noopener noreferrer"&gt;Upgrade a project to TanStack Start&lt;/a&gt;, Lovable&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.lovable.dev/integrations/github" rel="noopener noreferrer"&gt;Sync your Lovable project with GitHub&lt;/a&gt;, Lovable&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.lovable.dev/features/cloud" rel="noopener noreferrer"&gt;Built-in backend&lt;/a&gt;, Lovable&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://tanstack.com/start/latest/docs/framework/react/guide/hosting" rel="noopener noreferrer"&gt;TanStack Start hosting&lt;/a&gt;, TanStack&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://vite.dev/guide/env-and-mode" rel="noopener noreferrer"&gt;Env variables and modes&lt;/a&gt;, Vite&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://caddyserver.com/docs/automatic-https" rel="noopener noreferrer"&gt;Automatic HTTPS&lt;/a&gt;, Caddy&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://supabase.com/docs/guides/auth/redirect-urls" rel="noopener noreferrer"&gt;Redirect URLs&lt;/a&gt;, Supabase&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>lovable</category>
      <category>vite</category>
      <category>supabase</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
