Skip to content
On this page

Switchable Runtime (Alpha)

By default, Next.js uses Node.js as the runtime for page rendering, including pre-rendering and server-side rendering.

Note: runtime option only effects pages but not middleware

If you have React 18 installed, there is a new experimental feature that lets you switch the page runtime between Node.js and the Edge Runtime. Changing the runtime affects SSR streaming and Server Components features, as well.

Global Runtime Option

You can set the experimental option runtime to either 'nodejs' or 'edge' in your next.config.js file:

// next.config.js
module.exports = {
  experimental: {
    runtime: 'nodejs',

This option determines which runtime should be used as the default rendering runtime for all pages.

Page Runtime Option

On each page, you can optionally export a runtime config set to either 'nodejs' or 'edge':

export const config = {
  runtime: 'nodejs',

When both the per-page runtime and global runtime are set, the per-page runtime overrides the global runtime. If the per-page runtime is not set, the global runtime option will be used.

You can refer to the Switchable Next.js Runtime RFC for more information.

Note: The page runtime option is not supported in API Routes currently.