Skip to content

docs: add the Vercel deployment guide - #700

Merged
blove merged 9 commits into
mainfrom
docs/vercel-deployment-guide
Sep 17, 2026
Merged

blove merged 9 commits into
mainfrom
docs/vercel-deployment-guide

Conversation

@blove

@blove blove commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #684.

What

Adds /docs/deployment/vercel (apps/web/content/docs/deployment/vercel.mdx), the guide the vercel build target never had. @b4run/cli also ships a generated markdown copy of the docs, so this is where the deployment/vercel.md the issue asked for comes from.

It covers:

  • enabling build.targets: ["vercel"] and the four runtime packages the bundle imports;
  • the emitted Build Output API tree (config.json, index.func/.vc-config.json, index.func/index.mjs), the bundle validation, and the atomic publish behaviour;
  • vercel.json reconciliation as implemented, plus the build.vercel.reconcileVercelJson: false opt-out and the four B4_E1003 near misses it rejects;
  • DATABASE_URL through the Neon Marketplace integration, pooled pg for non-Neon hosts, and B4_PG_SCHEMA=$VERCEL_ENV to keep preview and production apart in one database;
  • maxDuration (not settable from b4 build, because the output validator pins .vc-config.json to three keys, so the project default applies) and streaming;
  • composing with a frontend, against the open vercel target: let the build describe static assets, extra functions and routes #679 / vercel target: function named index shadows a static index.html at / #687 limits and the manual tree assembly they force today;
  • a prebuilt CI flow (b4 build → vercel deploy --prebuilt --yes) with a minimal GitHub Actions workflow;
  • /healthz on this target, where the per-request store factory runs before dispatch, so the probe exercises DATABASE_URL;
  • running the built bundle locally with no proxy.

Kept current with three target changes that landed mid-review

This branch was opened against an older main and rebased three times, each time correcting a claim that had become false:

Landed Effect on the guide
#698 (closes #690) The local-run section required B4_PG_WS_PROXY and two Docker containers. Rewritten: pooled pg reaches a local Postgres directly, and the proxy is now described as a way to rehearse the Neon path, with the three value forms it accepts.
#697 (closes #681) The guide said flatly there is no reconciliation opt-out. Now documents build.vercel.reconcileVercelJson: false, what the build stops doing, and that Fluid must be enabled in project settings because nothing then checks it from source.
#699 The guide said a generated app requires an app-dedicated database. Now carries the B4_PG_SCHEMA=$VERCEL_ENV recipe and links to the edge page's table.

Conflicts resolved toward main throughout: configuration.mdx takes main's BuildTargetName union wording from #693, and cli.mdx takes main's vercel bullet with a link to this page appended.

Only #679 and #687 remain open, and the frontend section documents the manual tree post-processing they force.

Registration

  • Nav entry, page wrapper, SEO registry entry, regenerated lastmod.generated.json.
  • Vercel row and card on Deployment Options; Vercel added to the README target list.
  • Page-count pins bumped in nav.test.ts, sitemap.test.ts, seo.test.ts, audit-built-seo.mjs, check-docs.mjs, and packages/cli/test/docs-bundle.test.ts; the README contract test now also requires the Vercel link.

Verification

  • pnpm test: 6412 passed, 0 failed.
  • node scripts/check-docs.mjs passes against a full pnpm build.
  • pnpm lint 28/28; seo:lastmod:check clean.
  • Docs-only change on this branch; no changeset needed. The changesets in the diff came in from main.

Not a release.

🤖 Generated with Claude Code

Adds /docs/deployment/vercel, the guide the `vercel` build target never
had: enabling `build.targets: ["vercel"]`, the emitted Build Output API
tree and what each file is, the `vercel.json` reconciliation rules as
implemented (and that #681's opt-out has not landed), `DATABASE_URL`
wiring through the Neon Marketplace integration, `maxDuration` and
streaming, composing with a frontend against the open #679/#687 limits,
a prebuilt CI flow with a minimal GitHub Actions workflow, `/healthz`
behaviour on this target, and local execution of the bundle through a
wsproxy with the `B4_PG_WS_PROXY` host:port format from #690.

Registers the page everywhere the docs site requires it (nav, SEO
registry, lastmod manifest, page wrapper), adds a Vercel row and card to
Deployment Options, a `vercel` bullet to the CLI reference, and bumps
the pinned page counts in the nav, sitemap, SEO, audit, and check-docs
fixtures. Every command and option was checked against
packages/cli/src/lib/build/targets/vercel*.ts and web-runtime.ts.

Closes #684

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@vercel

vercel Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
b4-run Ready Ready Preview Sep 17, 2026 9:55pm UTC

Request Review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval: this PR received an intelligent (AI) code review. See the review comments on this PR.

`b4` ships a generated markdown copy of the docs site at
`packages/cli/docs/` (built by scripts/generate-docs.mjs, gitignored).
Adding the Vercel page to the nav makes the bundle emit one more topic
file, so the hard-coded topic count in docs-bundle.test.ts needs the
same bump the nav, sitemap, SEO, and audit pins already got.

The generated `deployment/vercel.md` itself needs no commit; it is
produced at build time from the new MDX page.

Co-Authored-By: Claude Opus 5 <[email protected]>
#698 landed while this branch was open and closed #690: the vercel
target's generated stores now select a driver per request, so the built
bundle reaches a plain local Postgres over pooled `pg` with no WebSocket
proxy at all. The guide documented the proxy as a hard requirement, so
that section was rewritten:

- the local recipe is now DATABASE_URL plus a bare `node --input-type=module`
  import, no Docker network and no wsproxy containers;
- `B4_PG_WS_PROXY` is described with the forms it actually accepts
  (host:port, ws://, wss://), as a way to rehearse the Neon path rather
  than as a precondition, alongside `B4_PG_DRIVER` and the
  proxy-with-pg configuration error;
- the driver detail links to the edge page's new "Database drivers"
  section instead of restating it;
- the fit check no longer claims WebSocket Postgres is required, and the
  Neon section notes non-Neon hosts get a pooled `pg` connection.

Conflicts resolved toward main: configuration.mdx takes main's
`BuildTargetName` union wording from #693, which already names both
edge targets, and lastmod.generated.json is regenerated.

Co-Authored-By: Claude Opus 5 <[email protected]>
…cing

Two more vercel-target changes landed while this branch was open, and
both contradicted the guide:

- #697 closed #681 by adding `build.vercel.reconcileVercelJson`. The
  guide said flatly that there is no opt-out. It now documents the flag,
  what `b4 build` stops doing when it is off, the four `B4_E1003` near
  misses that are rejected rather than read as configured, and that
  Fluid must then be enabled in the project settings because nothing
  checks it from source.
- #699 added `B4_PG_SCHEMA` and `B4_PG_TABLE_PREFIX`. The guide said a
  generated app requires an app-dedicated database. It now carries the
  `B4_PG_SCHEMA=$VERCEL_ENV` recipe, which is the Vercel-shaped reason
  the feature exists, and links to the edge page's table for the rest.

cli.mdx conflicted and takes main's `vercel` bullet, which already
covers the opt-out, with a link to this page appended.

Co-Authored-By: Claude Opus 5 <[email protected]>
#694 landed and inverted what this guide said about /healthz. Route
matching now happens before store construction, so:

- /healthz is pure liveness: no stores, 200 whenever the function serves
  HTTP, including with DATABASE_URL unset. The guide had said the
  opposite, that /healthz opens a pool and a bad connection string
  surfaces there as a 500;
- /readyz is the new dependency probe, and is what the guide now tells
  readers to hit after a deploy — with the two caveats that it reports
  real causes (hostnames, ports, driver codes) and that neither probe is
  gated by middleware or thread access.

/readyz is also added to the frontend routing lists and the deploy
checklist, and the local-bundle snippet now probes it, since /healthz no
longer proves anything about the database.

Co-Authored-By: Claude Opus 5 <[email protected]>
#695 landed two things this guide needed:

- `build.vercel.outDir` / `b4 build --out-dir <dir>`, with the flag
  winning over the config value, app-root-relative resolution, the
  rejection of a directory containing the app root, and the error when
  vercel is not a configured target;
- a relaxed output validator. `config.json` now needs version 3 and a
  route reaching `/index` rather than the exact catch-all, and extra
  routes and top-level keys are accepted.

Together those turn the frontend-composition section from a list of
workarounds into a supported flow: stage the runtime tree elsewhere,
assemble into `.vercel/output`, and a composed config still validates.
The section now says so, and says plainly that the validator runs on
what the target stages rather than on what an assembler produces, and
that renaming the function off `dest: "/index"` makes the final config
the author's responsibility.

Also records that the generated stores import
`@b4run/postgres-storage/node`, which reaches `pg` through that
package's own dependency so an app never declares `pg` itself — the one
real gap raised by the session that owns #698.

cli.mdx conflicted and takes main's bullet, which covers outDir and the
relaxed validator, with a link to this page appended.

Co-Authored-By: Claude Opus 5 <[email protected]>
Neither change affects this page. #705 batches route-discovery errors,
and #708 is the edge page's own local-run recipe switching from /healthz
to /readyz for the same reason this guide already did.

#691 was closed unmerged, so the emitted function directory is still
index.func and this page's shadowing argument stands unchanged.

Only the lastmod manifest conflicted; regenerated.

Co-Authored-By: Claude Opus 5 <[email protected]>
None of the three touches this page: verify registry error codes,
body-less middleware reject status, and a k8s smoke watchdog. Only the
generated SEO manifest conflicted, resolved by regenerating per the
procedure #712 added to AGENTS.md.

Co-Authored-By: Claude Opus 5 <[email protected]>
@blove
blove merged commit 5369c34 into main Sep 17, 2026
29 of 30 checks passed
@blove
blove deleted the docs/vercel-deployment-guide branch September 17, 2026 22:23
blove added a commit that referenced this pull request Sep 17, 2026
#700 added the guide against the pre-change behaviour: its compose section
said the target emits no static dir, no extra functions and no routes, and
cited #679/#687 as open proposals. Rewrite it around build.vercel, keep the
assemble-it-yourself path as a scoped subsection since outDir still serves
that case, and qualify the artifacts table as the bare-build shape.

Co-Authored-By: Claude Opus 5 <[email protected]>
blove added a commit that referenced this pull request Sep 17, 2026
…el build output (#696)

* docs: design for composed Vercel build output (#679)

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* feat(cli): resolve build.vercel config and relax the Vercel output validator

Pure resolver for build.vercel (functionName, static, functions, routes),
route composition in Build Output order, and a validator that accepts a
composed tree while keeping the runtime function config exact.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* feat(cli): compose static assets, extra functions, and routes into the Vercel build output

build.vercel describes the Build Output tree beyond the runtime function.
The target checks every configured path before touching .vercel/, copies
the static dir, bundles each extra function, orders routes as user routes
-> filesystem -> runtime -> SPA fallback, and validates the composed tree
before the existing atomic publish. The runtime function is b4.func when
static assets are configured so it does not shadow static/index.html.

Refs #679, #687

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* style: format Vercel target sources with the repo config and refresh SEO lastmod

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* chore(web): refresh SEO lastmod after merging main

Co-Authored-By: Claude Opus 5 <[email protected]>

* chore(web): refresh SEO lastmod after merging main

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(cli): route /readyz to the runtime under a Vercel SPA fallback

#694 added /readyz beside /healthz. The scoped runtime route a SPA fallback
installs did not list it, so on a composed Vercel deployment /readyz matched
the fallback and served the SPA document with a 200 rather than reaching the
runtime — a readiness probe that looks healthy while reporting nothing.

Add readyz, and cover the composed route with one case per rooted runtime
surface so a future surface cannot be added without updating it.

Co-Authored-By: Claude Opus 5 <[email protected]>

* test(cli): assert the composed runtime route from its exported constant

The integration test duplicated the route string, so adding /readyz to the
implementation left a stale literal asserting the old value. Reference the
constant instead.

Co-Authored-By: Claude Opus 5 <[email protected]>

* chore(web): refresh SEO lastmod after merging main

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(cli): declare response streaming on the Vercel runtime function

The runtime function's .vc-config.json carried only handler, launcherType
and runtime, so Vercel's Node launcher buffered its responses. The runtime
answers /agui/:routeId and /threads/:id/runs/stream with text/event-stream,
which meant a deployed frontend received nothing until a run finished
instead of tokens as they were produced. Extra functions configured through
build.vercel.functions could already opt into streaming; the one function
that always streams could not.

supportsResponseStreaming is fixed rather than configurable: it follows from
what the runtime serves, not from how the app is deployed. validateVercelOutput
keeps asserting the runtime config exactly, deriving both the written bytes and
the expectation from the same constant.

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(cli): give every build.vercel rejection the B4_E1003 code and docs link

resolveVercelComposition threw bare CliErrors, so a malformed
build.vercel.static.dir printed an uncoded line while an unknown
build.vercel key printed the coded, linked form check-error-codes.test.ts
asserts. Move the shared invalidBuildConfig helper into vercel-compose.ts,
which vercel-config.ts already depends on, and route every throw through it.

Also qualify the local-run snippet in the edge docs: the runtime function is
index.func only until build.vercel.static renames it.

Co-Authored-By: Claude Opus 5 <[email protected]>

* chore(web): refresh SEO lastmod after merging main

Co-Authored-By: Claude Opus 5 <[email protected]>

* docs(vercel): describe the composed tree in the Vercel guide

#700 added the guide against the pre-change behaviour: its compose section
said the target emits no static dir, no extra functions and no routes, and
cited #679/#687 as open proposals. Rewrite it around build.vercel, keep the
assemble-it-yourself path as a scoped subsection since outDir still serves
that case, and qualify the artifacts table as the bare-build shape.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
blove added a commit that referenced this pull request Sep 17, 2026
…716)

The runtime function's supportsResponseStreaming: true is what stops Vercel's Node launcher buffering the whole body; the page now names that mechanism and its symptom, and notes that a function declared under build.vercel.functions must ask for the flag itself.

The local-run snippet's functions/index.func/index.mjs is the bare build's path; a build configuring build.vercel.static emits b4.func, so the snippet now says so.

Follow-up to #700, audited against #696's source and tests.

Co-Authored-By: Claude Opus 5 <[email protected]>

This branch was successfully deployed

1 active and 1 inactive deployments
vercel-preview — 116765d7 Deployed Sep 17, 2026 by blove via vercel-native #2025
Preview — 116765d7 Deployed Sep 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant