opennextjs-cloudflare
CLI
The Cloudflare adapter provides a opennextjs-cloudflare
CLI to develop, build, and deploy your application. You should not use wrangler
commands directly unless documented otherwise or if you know what you are doing.
commands
opennextjs-cloudflare
support multiple commands, invoked via opennextjs-cloudflare <command>
.
The currently supported commands are build
, populateCache
, preview
, deploy
, and upload
.
You can list the commands by invoking pnpm opennextjs-cloudflare
and get help with a given command by invoking pnpm opennextjs-cloudflare <command> --help
.
Most commands take command specific options (i.e. pnpm opennextjs-cloudflare build --skipNextBuild --noMinify
) and also accept wrangler options (i.e. pnpm opennextjs-cloudflare build --config=/path/to/wrangler.jsonc --env=prod
).
build
command
It first builds the Next.js application by invoking the build
script of the package.json
- which typically execute next build
. It then runs the Cloudflare specific build step to update the built files to run on the Cloudflare runtime.
populateCache
command
It populates the configured Open Next cache components so that caching works at runtime. It can populate the local bindings (populateCache local
) used during development on your local machine or the remote bindings (populateCache remote
) used by the deployed application. Note that this command is implicitly called by the preview
, deploy
, and upload
commands so there is no need to explicitly call populateCache
when one of those is used.
preview
command
It starts by populating the local cache and then launches a local development server (via wrangler dev
) so that you can preview the application locally.
deploy
command
It starts by populating the remote cache and then deploys your application to Cloudflare (via wrangler deploy
). The application will start serving as soon as it is deployed.
upload
command
It starts by populating the remote cache and then uploads a version of your application to Cloudflare (via wrangler upload
). Note that the application will not automatically be served on uploads. See Gradual deployments (opens in a new tab) to learn more about how to serve an uploaded version.