npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@opennextjs/cloudflare

v0.2.1

Published

Cloudflare builder for next apps

Downloads

8,608

Readme

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