0.2.1 • Published 9 months ago

@opennextjs/cloudflare v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

OpenNext for Cloudflare

Deploy Next.js apps to Cloudflare!

OpenNext for Cloudflare is Cloudflare specific adapter that enables deployment of Next.js applications to Cloudflare.

Getting started

You can use create-next-app to start a new application or take an existing Next.js application and deploy it to Cloudflare using the following few steps:

Configure your app

  • add the following devDependencies to the package.json:

    npm add -D wrangler@latest @opennextjs/cloudflare
    # or
    pnpm add -D wrangler@latest @opennextjs/cloudflare
    # or
    yarn add -D wrangler@latest @opennextjs/cloudflare
    # or
    bun add -D wrangler@latest @opennextjs/cloudflare
  • add a wrangler.toml at the root of your project

    #:schema node_modules/wrangler/config-schema.json
    name = "<your-app-name>"
    main = ".worker-next/index.mjs"
    
    compatibility_date = "2024-09-23"
    compatibility_flags = ["nodejs_compat"]
    
    # Use the new Workers + Assets to host the static frontend files
    assets = { directory = ".worker-next/assets", binding = "ASSETS" }

You can enable Incremental Static Regeneration (ISR) by adding a KV binding named NEXT_CACHE_WORKERS_KV to your wrangler.toml:

  • Create the binding

    npx wrangler kv namespace create NEXT_CACHE_WORKERS_KV
    # or
    pnpm wrangler kv namespace create NEXT_CACHE_WORKERS_KV
    # or
    yarn wrangler kv namespace create NEXT_CACHE_WORKERS_KV
    # or
    bun wrangler kv namespace create NEXT_CACHE_WORKERS_KV
  • Paste the snippet to your wrangler.toml:

    [[kv_namespaces]]
    binding = "NEXT_CACHE_WORKERS_KV"
    id = "..."

!WARNING The current support for ISR is limited.

Local development

  • you can use the regular next CLI to start the Next.js dev server:

Local preview

Run the following commands to preview the production build of your application locally:

  • build the app and adapt it for Cloudflare

    npx cloudflare
    # or
    pnpm cloudflare
    # or
    yarn cloudflare
    # or
    bun cloudflare
  • Preview the app in Wrangler

    npx wrangler dev
    # or
    pnpm wrangler dev
    # or
    yarn wrangler dev
    # or
    bun wrangler dev

Deploy your app

Deploy your application to production with the following:

  • build the app and adapt it for Cloudflare

    npx cloudflare && npx wrangler deploy
    # or
    pnpm cloudflare && pnpm wrangler deploy
    # or
    yarn cloudflare && yarn wrangler deploy
    # or
    bun cloudflare && bun wrangler deploy
0.2.1

9 months ago

0.0.0-b997312

10 months ago

0.0.0-953d0b1

10 months ago

0.0.0-9a03245

10 months ago

0.0.0-e62af72

10 months ago

0.0.0-361f2b7

10 months ago

0.0.0-5105d31

10 months ago

0.0.0-3628be6

10 months ago

0.0.0-11802c4

10 months ago

0.0.0-9758666

10 months ago

0.0.0-af15fd1

10 months ago

0.0.0-28d3ca1

10 months ago

0.0.0-cf5113b

10 months ago

0.0.0-acc0c5e

10 months ago

0.0.0-59a1d9e

10 months ago

0.0.0-9aff12e

10 months ago

0.1.0

10 months ago

0.0.3

10 months ago

0.2.0

10 months ago

0.1.1

10 months ago

0.0.0-a1eae5e

10 months ago

0.0.0-42bf0ff

10 months ago

0.0.0-42320e7

10 months ago

0.0.0-e2c4535

10 months ago

0.0.0-698638

10 months ago

0.0.0-88fe982

10 months ago

0.0.0-fd3c2b9

10 months ago

0.0.0-5454280

10 months ago