Repository navigation
NF1: the apps on Workers - #2
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
next-forge's three deployable apps on Cloudflare Workers, one
@opennextjs/cloudflareWorker 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. BindsHYPERDRIVE(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. BindsRATE_LIMIT(KV).apps/api→next-forge-api-<env>: health, the Stripe and Clerk webhooks, and the daily keep-alive as a Cron Trigger (customworker.ts). BindsHYPERDRIVE.What changed for Cloudflare
database.pagecalls over postgres.js, one client per call on HyperdriveSTORAGE)AIbinding), OpenAI optionalfetchwhen a DSN is set/cron/keep-aliverouteEvery 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/storybookandapps/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 intests/{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) andorun catalog validate: pass.The infra roots and the migrations land in NF2.
Generated by Claude Code