Deploy Next.js apps to Cloudflare with OpenNext
mainnext build (in standalone mode) to run in the Cloudflare workerd runtime using the Workers Node.js compatibility layer.repository·main·Indexed 23 days ago
https://github.com/opennextjs/opennextjs-cloudflareAn adapter that allows Next.js applications to be deployed to the Cloudflare Workers runtime by adapting standalone Next.js builds to work with Cloudflare's Node.js compatibility layer. It provides a CLI for building and deploying, configuration via defineCloudflareConfig, and specialized handlers for asset resolution, cache purging (including Durable Objects), and incremental caching using Cloudflare R2.
next build (in standalone mode) to run in the Cloudflare workerd runtime using the Workers Node.js compatibility layer.The blog-starter example demonstrates Next.js Static Generation using Markdown files.
/_posts directory as Markdown files.gray-matter and passed as props to the page.remark and remark-html before being sent as props to the page.Next.js Middleware allows you to run code before a request is completed. In a standard Next.js setup:
middleware.ts file.matcher in the exported config object to filter which routes the middleware runs on.matcher from the exported config.redirect, rewrite, or allow normal request behavior.The benchmarking script performs full end-to-end performance testing against the example applications located in the ./examples directory. For each eligible application, the script executes the following workflow in parallel:
build:worker script.wrangler deploy.Note: Certain applications may be excluded from this process based on the exampleAppsNotToBenchmark configuration found in ./src/cloudflare.ts.
opennextjs-cloudflare CLI, then run it using wrangler.To test how your application behaves specifically on the Cloudflare runtime before deploying, use the preview script to run a local preview.
npm run previewTo start the development server for the Prisma example project, use your preferred package manager to run the dev script. Once running, you can view the application at http://localhost:3000 and edit app/page.tsx to see real-time updates.
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devTo start the local development environment for this Next.js project, use the standard development command. This will host the application at http://localhost:3000 and enable fast refresh (auto-updates) when you modify files like app/page.tsx.
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devTo deploy your OpenNext-powered Next.js application to Cloudflare, run the deploy script.
npm run deployTo start the Next.js development server for local development, run the dev script. The application will be available at http://localhost:3000. You can modify app/page.tsx to see real-time updates.
npm run dev