This monorepo includes a POC to see if it is possible to get a Next.js application built via next build (in standalone mode) to run in the Cloudflare workerd runtime.
Note
The code here is built based on the amazing work done by @mhart in https://github.com/mhart/nextjs-commerce
The repository contains two directories:
nextjs-worker-buildercontaining a package that can be used to build Cloudflare workers compatible output from Next.js applicationsnext-appscontaining Next.js application that use the above mentioned builder (currently it only containsapi-nodejs-hello-world)
Install the dependencies:
pnpm ibuild the worker with:
pnpm --filter nextjs-worker-builder buildor in watch mode with:
pnpm --filter nextjs-worker-builder build:watchbuild and preview the worker for the api-nodejs-hello-world application:
pnpm --filter api-nodejs-hello-world preview:workerYou can skip building the next app when it has not been modified:
SKIP_NEXT_APP_BUILD=true pnpm --filter api-nodejs-hello-world preview:worker