Skip to main content
This page extends the Start bridge v0 contract with two additive pieces: an RSC-based generic page adapter, so a converted app needs no hand-written page models, and a codemod that converts a Next satellite with no hand edits. Production is unchanged; conversion produces a staging candidate only.

Generic page adapter (RSC mode)

Next pages are async server components with 'use client' islands. Start’s RSC environment (@tanstack/react-start RSC mode with @vitejs/plugin-rsc) runs that code with the same boundaries Next enforces, so retained page source renders unchanged. Per request, a Start server function in the app (generated src/start-bridge/page-route.tsx) calls resolveBridgePage from start/page-render:
  1. Resolve the location the app sees (start/page-location): on SSR the request the handler forwarded after proxy.ts, so rewrites apply while the browser keeps its URL; on client navigation the app proxy runs for the target, so the same URL renders the same page, a proxy redirect becomes a Start redirect and any other terminal response reloads the document. Match that app-relative path (mount stripped; a leading locale segment addresses a manifest with a stripped [locale]) against the generated page manifest. A localized page for the stripped path wins over a dynamic segment that would capture the locale (/en is the landing page, not workspace en); a page whose first segment is literally the locale still wins. No match answers 404.
  2. Load the page and its layout/template chain from the generated page-modules.bridge.gen.ts (lazy imports keyed by the manifest file).
  3. Pass Next’s props: params and searchParams as Promises; repeated query keys become arrays. A stripped [locale] segment resolves from the middleware x-next-intl-locale header, then NEXT_LOCALE, then the default.
  4. Merge metadata/generateMetadata and viewport like Next (shallow merge, nearest title.template) and convert them to head() data.
  5. Lift the root layout’s <html>/<body> attributes into the Start shell (createBridgeRootRoute). Server-component wrappers and the RSC CSS fragment around the root layout are expanded first; client references are never called.
  6. Await async pages and layouts before streaming, so notFound() and redirect() in their bodies answer 404 and redirect. Sync server components stay elements because they may call hooks.
  7. Return the tree through renderServerComponent; the catch-all and index routes render it, on SSR and on client navigation alike.

Route handlers run in the rsc environment

plugin-rsc rejects server-only in every environment except rsc, and the Worker entry is bundled in ssr. The generated vite.config.mts registers the API registry as the bridge-api rsc entry (rscEntries), and cloudflare/worker.ts loads it with import.meta.viteRsc.loadModule('rsc', 'bridge-api') before building the handler. Route modules (and the server-only packages they import) are compiled once, in rsc; the request store is global, so next/headers, cookies and the mount see the same request. Never alias or disable plugin-rsc’s import validation to make a build pass. redirect() from next/navigation keeps an absolute URL absolute, as in Next. Start’s router reduces a same-origin absolute href to its path, and on the apex Web’s https://tuturuuu.com/login is same-origin with tuturuuu.com/<app>, so the bridge marks the target for its response finalization (which otherwise adds the mount) and sets reloadDocument for client navigation. Without it, a mounted app’s login redirect loops into its own /<app>/login. Fonts from next/font resolve to inert objects; load font CSS through the app stylesheet. A page that needs Next behaviour the adapter lacks (parallel or intercepting routes) stays a hand-written page via owned/ignored in start-bridge.routes.json.

Converting an app

The dry run reads only. --apply writes the same change set and installs the pinned toolchain through bun add --exact in the app workspace; dependencies are never edited into package.json by hand. The toolchain includes the repository’s exact @cloudflare/workers-types pin, which the native binding type check resolves from the app. The app’s .gitignore gains .void/ and .void-wrangler.jsonc (local vp build output) when missing, appended after its own lines. Re-running an applied app, including one that already added a pin by hand, is a no-op. Every owned file carries a “Generated by the start-bridge codemod” marker; an unmarked hand-written file is a conflict that blocks --apply unless --adopt is passed. Codegen errors (an unregistered route.*/page.*), a missing src/proxy.ts and, with --hold, a missing Vercel publisher also block. Owned files and the app’s JSON edits are formatted with the repository’s Oxc. The codemod writes or edits:
  • start-bridge.routes.json (hand-maintained owned/ignored entries win on re-runs) and the bridge codegen registries, plus page-modules.bridge.gen.ts and public-assets.bridge.gen.ts.
  • vite.config.mts (preset in RSC mode), void.config.ts (the held tuturuuu-<app>-vite-staging Worker with TUTURUUU_NOINDEX=1 and the nodejs_compat and global_fetch_strictly_public flags; the latter sends same-zone self-fetches such as app-base appUrl(path, request.url) to the Worker instead of the zone origin, the retained Vercel app), cloudflare/worker.ts (mounts: <app>.tuturuuu.com root and the tuturuuu.com/<app> mount), tsconfig.cloudflare.json.
  • src/start.ts (bridgeServerFnFetch), src/router.tsx (routerBasepath(), ssr: { nonce: requestNonce() }), the root/index/catch-all routes and routeTree.gen.ts. The Worker does not enforce csp by default: each app adds createBridgeHandler({ csp }) with a policy that fits its scripts before it mounts on the apex.
  • Package scripts build:cloudflare, dev:cloudflare, preview:cloudflare (--configLoader runner), routes:check and type-check:cloudflare. build stays next build, so the current Vercel deployment is unchanged.
  • .env.example moves to env.example: Void accepts only .env.
  • The .oxfmtrc.json and .oxlintrc.json override that keeps every generated routeTree.gen.ts out of Oxc (formatter, linter and assist off), once for the repository. TanStack’s generator rewrites the file in its own format on each build, and bun check:changed passes changed files to Oxc explicitly.
  • With --hold only, the held record: tuturuuu.ci.ts productionPublicationPolicy, the protected surface in scripts/ci/production-publication-policy.ts and its regression’s app list, and the production-policy gate in vercel-production-<app>.yaml (as for Shortener).
  • tsconfig.json excludes the Start-only sources, so the existing Next type-check is unchanged; type-check:cloudflare checks them against tsconfig.cloudflare.json.
A held record also holds that app’s vercel-production-<app>.yaml, so the current Vercel production deployment freezes until the cutover admits the app. Conversion PRs therefore run without --hold; the app’s cutover-prep PR adds the hold and merges just before the flip.

Worker options

start-bridge.config.ts at the app root is app-owned: the codemod creates it once (with the shared response policy below) and never updates or replaces it. The generated cloudflare/worker.ts passes its options on, so an app changes Worker behaviour without editing generated files: API paths the app owns but forwards (Storefront’s Inventory APIs) are listed client-safely in start-bridge.routes.json as "api": { "forwarded": ["/api/v1/inventory/[...path]"] }. The codegen merges them into appApiPatterns, so the shared app-base resolver mounts them like local routes, and the Worker, finding no local handler, forwards them through apiOrigin. start-bridge.config.ts holds server code and is never imported by the browser. The codemod and the runtime test load it with Node’s type stripping, so keep its imports strippable (packages, or relative paths with their .ts extension).

Response policy

Every app uses one tested policy instead of hand-rolled wrapResponse code, which in four separate reviews kept repeating the same three bugs:
  • caching set only as a default, so a handler’s public, max-age survived;
  • an asset exemption that ignored the method, so POST /assets/x escaped;
  • an existing CSP passed through without frame-ancestors.
  • Every response gets:
    • X-Robots-Tag from seo. appRobots reads the app’s seo-policy.json entry, which the codemod emits into the generated Worker (no runtime JSON). A response is left indexable only on the public allowlist on the canonical origin, outside reserved paths (api, login, dashboard, embed, …, in any letter case, as Next’s header sources match). Each path segment is decoded once before both checks, so /%61uth is /auth, and a malformed escape, an encoded / or \, or a double encoding stays private. Staging deployments (TUTURUUU_NOINDEX=1) are never indexable either. Everything else gets PRIVATE_ROBOTS_HEADER. An upstream noindex is never overridden;
    • X-Content-Type-Options: nosniff and Referrer-Policy: strict-origin-when-cross-origin;
    • outside framable paths, X-Frame-Options: DENY, and frame-ancestors 'none' in every CSP policy. An existing frame-ancestors is replaced in any letter case, each comma-separated or repeated header policy is covered, and a response without a CSP gets csp (default frame-ancestors 'none').
  • Caching: only GET/HEAD requests for /assets/* or the app’s public files keep their own caching, unless they answer HTML. Every other response is set, not defaulted, to Cache-Control: private, no-store, and gains Vary: Cookie.
  • Framable paths: the platform list (@tuturuuu/utils/framable-paths, Web’s uploaded WebGL builds at /api/v1/workspaces/*/external-projects/assets/*/webgl), the app’s framablePaths and the policy’s own framable. These keep the upstream CSP byte-for-byte, or its absence, and any upstream X-Frame-Options (DENY/SAMEORIGIN) is removed. Web’s sandbox allow-scripts ... policy must reach the browser, or uploaded scripts run unsandboxed on the app origin. The handler csp skips the platform list and app-config framablePaths. The policy-only framable option leaves the CSP it receives unchanged and does not bypass the handler; use app-config framablePaths when the app sets csp. Matching is case-sensitive, unlike Next’s header source matching; that’s harmless because central’s routes are case-sensitive. One stateless matcher is shared by the handler and the policy: g/y patterns are cloned without those flags, so lastIndex never changes a result.
  • Failures: a throw in the proxy, an endpoint, Start or the route load answers the bridge’s generic 500 Internal Server Error. The details go only to console.error, and the response still goes through wrapResponse, so it gets no-store, robots and framing headers too. Hand-rolled wrappers that apps keep until they migrate also receive this generic 500, where a handler throw used to escape uncaught. They still run, and still see no error details.
  • Paths: framable and asset paths are matched app-relative, so on the tuturuuu.com/<app> mount the base is stripped first. WebSocket upgrades (101) pass through untouched.
Migrating an app with a hand-rolled wrapResponse (Finance, Tasks, Track, Storefront):
  1. Replace the function with createRootResponsePolicy({ seo }). Put shared framing exceptions in app-config framablePaths, as above. Keep the app’s robots value as seo, for example 'noindex, nofollow, nosnippet'.
  2. Drop any import of ./src/start-bridge/public-assets.bridge.gen. The Worker now passes publicAssets, and an extensionless relative import cannot be loaded by the codemod or the runtime test, which read the config with Node’s type stripping.
  3. Keep csp (the nonce policy) as it is. The response policy adds frame-ancestors 'none' to it.
  4. Re-run the codemod for the app, so its cloudflare/worker.ts passes mounts and publicAssets, then run bun check:changed.

Route handlers load lazily

The generated API registry (api.lazy) imports each route on its first request (lazyRouteModule), with the route’s HTTP methods read statically from its source so OPTIONS and 405 need no import. One route’s dependencies (for example a Node-only SDK chain) therefore cannot fail the Worker at startup; a route that re-exports with export * stays eager. In the rsc build, CommonJS require() of Node built-ins becomes an ESM import served by nodejs_compat, and .wasm/.bin imports become Wrangler CompiledWasm/Data modules (as next/og’s Workers port needs). An app whose Worker code runs in native SSR (rsc: { enabled: false }, as Calendar does) opts its ssr environment into the same conversion by adding startBridgeNodeBuiltinsPlugin() from @tuturuuu/start-bridge/vite/rsc to its Vite plugins. Generated apps get it in vite.config.mts by default, before voidPlugin(): their SSR bundles CommonJS too (Forms: sanitize-html, then postcss’s require('path')). This is the same conversion the rsc environment always applies, so a built-in workerd lacks fails when the chunk loads, which the runtime gate exercises, rather than when the code runs. A route that needs a Node API workerd does not provide still fails when it is hit; serve it from Web (centralFirst) or port it.

Native CI

When the repository has the reusable .github/workflows/native-start-app.yaml (#6753), the codemod also writes the app’s qualification CI, modelled on Shortener:
  • .github/workflows/<app>-cloudflare.yaml: a thin workflow_call caller with path filters for the app, its transitive workspace dependencies, the template and the shared native CI scripts, and Shortener’s inputs. An app without a test script runs its Vitest suite with --passWithNoTests. Registered in tuturuuu.ci.ts.
  • scripts/ci/<app>-native-artifact.py: the app’s Worker identity and public files over scripts/ci/apps-native-artifact.py.
  • cloudflare/native-built-worker.runtime.mjs (test:runtime, run with node --test after the build; not a *.test.* file, so source test runs never pick it up): a generic emitted-Worker smoke run on the sealed artifact, with all egress denied: Worker identity, public-file parity, build identity when the app has /api/build-info (read anonymously, as production smoke does: an app whose proxy guards API routes must admit exact GET/HEAD /api/build-info), the page outcomes the app declares, no server error on an unknown path, and the response policy (no-store, X-Robots-Tag, X-Frame-Options: DENY and frame-ancestors 'none') on real responses, after checking their status and content: a page rendering 200 HTML (by default the first runtime path expecting 200), a 200 JSON API response (/api/build-info) and a 404 HTML page (/__native-smoke-missing__). runtimeProbes in start-bridge.routes.json overrides a probe’s path, or skips it with { "skip": "<reason>" }. A skipped page or 404 probe must also name the app’s own runtime test that covers it, as "fixture": "cloudflare/<name>.runtime.mjs". For example, an auth-only app whose / redirects to login names its isolated-auth fixture. The fixture must be a distinct app-owned file that test:runtime’s cloudflare/*.runtime.mjs glob selects: never the generated gate itself, and never a dotfile, which the glob skips. The codemod and the gate both check this and that the fixture exists, and at least one probe must always run. A probe the codemod can neither default nor find declared, or a set that skips every probe, is a codemod problem. The test reads the Worker’s effective mounts (the generated defaults plus mounts in the app-owned start-bridge.config.ts, loaded with Node’s type stripping, so keep that file’s imports strippable) and probes with raw Host headers: every configured root host serves /. A mounted app serves every declared page on tuturuuu.com/<app>. A root-only app (no tuturuuu.com in mountHosts) must set unknownHost: 'reject', and the bridge must reject its apex paths and an unknown host with its own 404 before any app code runs, with no egress. Page outcomes come from runtime in start-bridge.routes.json (default { "/": 200 }): a record that must declare /, mapping app-relative paths to an exact status or { "redirect": "<path or absolute URL>" }. A path redirect must stay on the requested origin and, on the apex, keep the /<app> mount, so a login redirect, a cross-origin hop or a jump to another app never passes. The codemod rejects empty, array or root-less maps, and scripts/start-bridge-codemod/runtime-outcome.mjs holds the shared checks. App-specific acceptance goes in further cloudflare/*.runtime.mjs files, which test:runtime (node --test cloudflare/*.runtime.mjs) runs with it.
There is no publisher: production stays with the held record and the cutover PR.

Signed-in root browser gate

scripts/ci/native-root-browser.mjs checks what the generated runtime test cannot reach: signed-in SSR and client hydration in a real browser. It runs on a build host with Chromium against the app’s restored, sealed artifact:
The gate:
  • Verifies the artifact against the receipt, starts it in local workerd at the app’s root host, and checks that build-info names the exact source.
  • Signs a disposable app session with a random coordination secret.
  • Answers every Supabase and Web request in-process: the fixture user, the profile’s rows and Web responses, empty reads, and 401 for any other Web API read. A request to the app’s own root host goes back to the Worker under test, as a same-zone fetch does in production under global_fetch_strictly_public. A self-fetch loop (more than 8 nested or 200 total) is stopped with 508 and fails the run. Any other Worker or browser request fails the run, and an SSR failure lists it.
  • For each locale, follows the signed-in SSR redirects. They must stay on the root host and end on a 200 page with <html lang>, emitted assets and private, no-store. Chromium then loads the same path and must hydrate.
  • Fails on page errors or failed /assets/*, and re-verifies the artifact at the end.
The gate only drives a Worker it started on loopback. It takes no URL and refuses a non-loopback origin, so it never runs against a hosted deployment. Hosted signed-in acceptance stays a staging step with real accounts. Each app owns its profile at apps/<app>/cloudflare/root-browser.profile.mjs (a default-export object, no imports): Regressions for the profile, session, egress, self-fetch and SSR rules, and a check that every apps/*/cloudflare/root-browser.profile.mjs is valid, run with node --test scripts/ci/native-root-browser.test.mjs.

Generator inputs

The codemod reads app-specific behaviour from the app’s existing configuration, so apps regenerate instead of forking generated files: The preset renders @tuturuuu/vercel’s Analytics and Speed Insights as nothing, because Workers serve no /_vercel/* scripts; an app with an explicit shims list opts in with inertVercel: true. Each environment bundle (browser, SSR, rsc) carries its own internal-api module, so the registration is imported by src/router.tsx, the page route and the rsc API entry (src/start-bridge/api-entry.ts).

Coverage report

The report classifies each page through its layouts and local import graph. A page is generic unless it reaches an unshimmed framework specifier or a parallel/intercepting segment. The shim list follows the bridge preset; 'use server' modules and next/og are features, not blockers.

Verification

Codemod regressions run with node scripts/start-bridge-codemod/<file>.test.mjs on disposable fixture repositories; edits to repository files are tested against the real anchors. Each converted app still needs exact-commit CI: unit, types, lint, the real vp build, the sealed artifact and the emitted-runtime and browser acceptance.