Skip to content

Supported features

Supported Next.js versions

@cloudflare/next-on-pages supports all minor and patch version of Next.js 13 and 14. We regularly run manual and automated tests to ensure compatibility.

Node.js

Next.js has two “runtimes” — “Edge” and “Node.js”. When you run your Next.js app on Cloudflare, you can use available Node.js APIs — but you currently can only use Next.js’ “Edge” runtime.

The Workers runtime supports a broad set of Node.js APIs — but the Next.js Edge Runtime code intentionally constrains this. As a result, only the following Node.js APIs work in a Next.js app:

  • buffer
  • events
  • assert
  • util
  • async_hooks

Supported Features

Routers

Cloudlflare recommends using the App router from Next.js.

Cloudflare also supports the older Pages router from Next.js.

next.config.mjs Properties

next.config.js — app router and `next.config.js - pages router

OptionNext DocsSupport
appDirapp
assetPrefixpages, app🔄
basePathpages, app
compresspages, appN/A1
devIndicatorspages, appN/A2
distDirpages, appN/A3
envpages, app
eslintpages, app
exportPathMappages, appN/A4
generateBuildIdpages, app
generateEtagspages, app🔄
headerspages, app
httpAgentOptionspages, appN/A
imagespages, app
incrementalCacheHandlerPathapp🔄
loggingappN/A5
mdxRsapp
onDemandEntriespages, appN/A6
optimizePackageImportsapp✅/N/A7
outputpages, appN/A8
pageExtensionspages, app
Partial Prerendering (experimental)app9
poweredByHeaderpages, app🔄
productionBrowserSourceMapspages, app🔄10
reactStrictModepages, app11
redirectspages, app
rewritespages, app
Runtime Configpages, app12
serverActionsapp
serverComponentsExternalPackagesappN/A13
trailingSlashpages, app
transpilePackagespages, app
turbopages, app🔄
typedRoutesapp
typescriptpages, app
urlImportspages, app
webpackpages, app
webVitalsAttributionpages, app
- ✅: Supported
- 🔄: Not currently supported
- ❌: Not supported
- N/A: Not applicable

Internationalization

Cloudflare also supports Next.js’ internationalized (i18n) routing.

Rendering and Data Fetching

Incremental Static Regeneration

If you use Incremental Static Regeneration (ISR)14, @cloudflare/next-on-pages will use static fallback files that are generated by the build process.

This means that your application will still correctly serve your ISR/prerendered pages (but without the regeneration aspect). If this causes issues for your application, change your pages to use server side rendering (SSR) instead.

Background

ISR pages are built by the Vercel CLI to generate Vercel Prerender Functions. These are Node.js serverless functions that can be called in the background while serving the page from the cache.

It is not possible to use these with Cloudflare Pages and they are not compatible with the edge runtime currently.

Dynamic handling of static routes

@cloudflare/next-on-pages supports standard statically generated routes.

It does not support dynamic Node.js-based on-demand handling of such routes.

For more details see:

Caching and Data Revalidation

Revalidation and next/cache are supported on Cloudflare Pages and can use various bindings. For more information, see our caching documentation.

Footnotes

  1. compression: Cloudflare applies gzip or brotli compression automatically. When developing locally with Wrangler, no compression is applied.

  2. dev indicators: If you’re developing using wrangler pages dev, it hard refreshes your application the dev indicator doesn’t appear. If you run your app locally using next dev, this option works fine.

  3. setting custom build directory: Applications built using @cloudflare/next-on-pages don’t rely on the .next directory so this option isn’t really applicable (the @cloudflare/next-on-pages equivalent is to use the --outdir flag).

  4. exportPathMap: Option used for SSG not applicable for apps built using @cloudflare/next-on-pages.

  5. logging: If you’re developing using wrangler pages dev, the extra logging is not applied (since you are effectively running a production build). If you run your app locally using next dev, this option works fine.

  6. onDemandEntries: Not applicable since it’s an option for the Next.js server during development which we don’t rely on.

  7. optimizePackageImports: @cloudflare/next-on-pages performs chunks deduplication and provides an implementation based on modules lazy loading, based on this applying an optimizePackageImports doesn’t have an impact on the output produced by the CLI. This configuration can still however be used to speed up the build process (both when running next dev or when generating a production build).

  8. output: @cloudflare/next-on-pages works with the standard Next.js output, standalone is incompatible with it, export is used to generate a static site which doesn’t need @cloudflare/next-on-pages to run.

  9. Partial Prerendering (experimental): As presented in the official Next.js documentation: Partial Prerendering is designed for the Node.js runtime only., as such it is fundamentally incompatibly with @cloudflare/next-on-pages (which only works on the edge runtime).

  10. productionBrowserSourceMaps: The webpack chunks deduplication performed by @cloudflare/next-on-pages doesn’t currently preserve source maps in any case so this option can’t be implemented either. In the future we might try to preserver source maps, in such case it should be simple to also support this option.

  11. reactStrictMode: Currently we build the application so react strict mode (being a local dev feature) doesn’t work either way. If we can make strict mode work, this option will most likely work straight away.

  12. runtime configuration: We could look into implementing the runtime configuration but it is probably not worth it since it is a legacy configuration and environment variables should be used instead.

  13. serverComponentsExternalPackages: This option is for applications running on Node.js so it’s not relevant to applications running on Cloudflare Pages.

  14. Incremental Static Regeneration (ISR) is a rendering mode in Next.js that allows you to automatically cache and periodically regenerate pages with fresh data.