Course map
Stage 1: App Router Foundations
Stage 2: The Rendering Model
Stage 3: Data, Caching and Mutations
Stage 4: Full-Stack Next.js
Stage 5: Production and Specialization

Part 18 / Topic 4 of 8

The real finding: a standalone deployment's SQLite file is a build-time snapshot, not your live data

Posting a new entry through the standalone server (section 2's PORT=3101 instance) via a real curl multipart Server Action POST — Part 12's exact recipe, built from the real $ACTION_ID_... hidden field this build's own /mandi/guestbook page rendered:

$ curl -s -D - -X POST http://localhost:3101/mandi/guestbook \
    -F '$ACTION_ID_4027521b2b1f6f3bec6a2e89e6190dce4d59f90f5e=' \
    -F 'name=Standalone Tester' -F 'message=Checking which sqlite file this hits'
HTTP/1.1 200 OK
...<li><strong>Standalone Tester</strong>: Checking which sqlite file this hits</li>...

It worked — the new entry shows up immediately on the standalone server's own response. Checking which file actually received that row, directly, with a separate read-only connection to each:

$ node -e "... new Database('app/mandi/guestbook/mandi-guestbook.sqlite', {readonly:true}) ..."
project db: { c: 0 }
$ node -e "... new Database('.next/standalone/app/mandi/guestbook/mandi-guestbook.sqlite', {readonly:true}) ..."
standalone db: { c: 1 }

The project's own app/mandi/guestbook/mandi-guestbook.sqlite — the file every other part of this course reads and writes — stayed at zero entries. The row landed in .next/standalone's own copy instead. output: "standalone"'s file tracer (@vercel/nft) determined this file was needed by actually exercising the server module during the build's page-data-collection step — which means the file it copied is a build-time snapshot, physically separate from the project directory from the moment npm run build finishes. Every write a running node .next/standalone/server.js process makes from then on goes into that snapshot, not your project's working database, and the two will silently diverge forever unless something explicitly keeps them in sync. (A related, secondary finding from the same investigation: reading the traced copy with a fresh, separate script sometimes reports no such table — because the trace can capture the main .sqlite file without its -wal sidecar fully flushed, Part 16's own WAL mechanism; the running server never hits this itself, because db.ts's CREATE TABLE IF NOT EXISTS migration re-runs unconditionally on every module load and silently "self-heals" the schema either way — but a raw script bypassing that migration can see a seemingly broken, table-less file.)

This is this course's own capstone confirming, concretely, exactly what self-hosting.md warns about in the abstract (section 7): a local file — SQLite included — is not a deployment artifact you can trust to carry live data across a build. A real deployment of this capstone would need either a managed database reachable over the network from every instance, or an explicit step that copies/syncs the database file into the deployment artifact on every release, not a trace that happens to pick it up once.

Done here? The practice set for Part 18 — including the solutions — is on the part page.

Search the guide