Deploy to Cloudflare Pages (free hosting)#22
Open
chanind wants to merge 3 commits into
Open
Conversation
Run the existing Next.js app on Cloudflare's edge network using @cloudflare/next-on-pages. Free tier: unlimited requests and bandwidth. Key changes: - Add @cloudflare/next-on-pages for building - Add buildStaticData.ts to pre-chunk commit/item data into small JSON files served as static assets - Add edgeDatabase.ts that fetches data chunks via HTTP instead of readFileSync (which isn't available on edge) - Dynamic pages (commit/item) use experimental-edge runtime and fetch data from chunked static assets - Changelog pages pre-render all paths at build time (Node.js) Build: yarn pages:build Deploy: npx wrangler pages deploy .vercel/output/static Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The vercel package (dependency of @cloudflare/next-on-pages) requires Node >= 18. Also update checkout and setup-node actions to v4. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
@cloudflare/next-on-pagesfallback: "blocking",<Link>, redirectsHow it works
The main challenge is that Cloudflare Workers don't have a filesystem, so
readFileSyncdoesn't work at runtime. The solution:scripts/buildStaticData.tspre-chunks the large CHANGELOG JSON files into ~256 small JSON files per version, served as static assetsdata/edgeDatabase.tsfetches the specific chunk needed viafetch()at runtime (same-origin, fast)experimental-edgeruntime and fetch data from static chunks on-demandTest plan
yarn pages:buildcompletes successfully (~30s)To deploy
Or connect the repo to Cloudflare Pages with build command:
cd website && yarn install && yarn pages:build🤖 Generated with Claude Code