Skip to content

NF1: the apps on Workers - #2

Merged
ruehowl merged 1 commit into
mainfrom
nf/1-apps-on-workers
Oct 28, 2026
Merged

ruehowl merged 1 commit into
mainfrom
nf/1-apps-on-workers

Conversation

@ruehowl

@ruehowl ruehowl commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

next-forge's three deployable apps on Cloudflare Workers, one @opennextjs/cloudflare Worker each, over the upstream @repo/* packages (vercel/next-forge, MIT).

The apps

  • apps/app → next-forge-app-<env>: the dashboard, the database page, search, the Svix webhooks portal, Liveblocks and Knock. Binds HYPERDRIVE (Supabase Postgres), STORAGE (R2), AI (Workers AI).
  • apps/web → next-forge-web-<env>: home, pricing, blog, legal pages and the contact form in six languages. Binds RATE_LIMIT (KV).
  • apps/api → next-forge-api-<env>: health, the Stripe and Clerk webhooks, and the daily keep-alive as a Cron Trigger (custom worker.ts). Binds HYPERDRIVE.

What changed for Cloudflare

Upstream Here
Prisma 7 on Neon the same database.page calls over postgres.js, one client per call on Hyperdrive
Vercel Blob R2 (STORAGE)
Upstash rate limit the same sliding-window API over Workers KV
OpenAI via the AI SDK Workers AI (AI binding), OpenAI optional
Sentry / BetterStack SDKs Workers Logs; Sentry over fetch when a DSN is set
Vercel Cron a Cron Trigger running the same /cron/keep-alive route
Vercel Analytics, Vercel Toolbar not carried (Vercel-only)
Arcjet not carried: its 3.6 MB WASM analyzer alone puts the app over Workers Free's 3 MiB; Cloudflare's WAF and bot rules cover it on a custom domain
BaseHub's all-language Shiki code block Shiki with a blog's usual languages on its JS regex engine (1.7 MB less)
Clerk required optional: a sample user under a notice; sign-in says what to set
BaseHub with no token: an empty blog sample posts and legal pages under a notice

Every SaaS key is an optional Orun secret (optionalSecretEnv): public ones are inlined at build, server ones are kept out of the build and pushed as Worker secrets. apps/docs (Mintlify), apps/email (react-email preview), apps/storybook and apps/studio (Prisma Studio) are dev tools or other hosts and are not carried.

Checked locally

  • pnpm install --frozen-lockfile, wire:fixture (no diff), typecheck, lint, test (47 tests in tests/{app,web,api}), build: green.
  • wrangler deploy --dry-run: app 2,869 KiB, web 2,602 KiB, api 1,315 KiB gzip — all under 3 MiB.
  • wrangler dev, no key set: every web route (sample blog, six locales, /api/health), the app's dashboard as the sample user against a local Postgres, the API's health, keep-alive and its Cron Trigger.
  • orun plan (push to main) and orun catalog validate: pass.

The infra roots and the migrations land in NF2.


Generated by Claude Code

next-forge's three deployable apps — the product (apps/app), the marketing
site (apps/web) and the API (apps/api) — each built by @opennextjs/cloudflare
into its own Worker with Static Assets, over the upstream @repo/* packages,
under pnpm 10 and Node 22 with the baselines' ESLint 9, typecheck and vitest
shape. Next 16.4.3 (OpenNext 1.20.13 needs >= 16.4.1), webpack builds (the
packages listed as transpilePackages), dependencies resolved to the versions
upstream's lockfile pins.

What changed for Cloudflare, and why:
- @repo/database: Prisma 7 on Neon -> the same database.page calls over
  postgres.js, one client per call on the HYPERDRIVE binding.
- @repo/storage: Vercel Blob -> the STORAGE R2 binding; @repo/rate-limit:
  Upstash Redis -> the same sliding-window API over a RATE_LIMIT KV namespace;
  @repo/ai: OpenAI -> Workers AI through the AI binding (OpenAI optional).
- @repo/observability: @sentry/nextjs and @logtail/next -> Workers Logs, with
  errors posted to Sentry over fetch when a DSN is set.
- The API's Vercel cron -> a Cron Trigger on a custom worker.ts that runs the
  same /cron/keep-alive route; the Stripe webhook verified with
  constructEventAsync over SubtleCrypto.
- Vercel-only pieces dropped: Vercel Analytics, the Vercel Toolbar and its
  flags endpoint. Arcjet dropped: its 3.6 MB WASM analyzer alone puts the app
  over Workers Free's 3 MiB; Cloudflare's WAF and bot rules cover it on a
  custom domain. BaseHub's all-language Shiki code block -> Shiki with a
  blog's usual languages on its JS regex engine (1.7 MB less in the site).
- Every SaaS optional: Clerk missing -> the app runs as a sample user under a
  notice and sign-in says what to set; BaseHub missing -> sample posts and
  legal pages; Svix missing -> the webhooks page says so instead of a 500.
- A health route on the app (Hyperdrive) and the site (KV) for the deploys'
  smokes; each app's wrangler template, fixture, committed render and
  component.yaml (server secrets kept out of the build and pushed as Worker
  secrets).

Measured: dry-run sizes app 2,869 KiB, web 2,602 KiB, api 1,315 KiB gzip;
wrangler dev serves every route with no key set. apps/docs (Mintlify),
apps/email (react-email's preview server), apps/storybook and apps/studio
(Prisma Studio) are not carried. tests/{app,web,api}: 47 tests.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019PcpNVpFBcbeiX3EHdXfmn
@ruehowl
ruehowl merged commit 47bf9cb into main Oct 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants