Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Next.js 16+ · Const

runtime

runtime selects the JavaScript runtime used to render a Next.js route segment. Node.js is the default; the documentation marks Edge as deprecated.

How it works

Export runtime from a page, layout, or route handler to choose the JavaScript runtime used to render that route segment. Use 'nodejs' for the supported default runtime; the page identifies 'edge' as deprecated.

Syntax

export const runtime = 'nodejs'

Parameters

NameTypeDescription
runtime'nodejs' | 'edge' (deprecated)The JavaScript runtime for the route segment; the documented default is Node.js.

Returns

No runtime value is returned; exporting the constant configures route rendering.

Key points

  • Use this export to choose which JavaScript runtime renders a route.
  • The documentation currently labels the Edge Runtime as deprecated.
  • Migration away from Edge consists of removing the runtime export from affected route files.

Common mistakes

  • Do not choose 'edge' for new code; the documentation marks it as deprecated.
  • When migrating away from Edge, remove the export instead of replacing it with another Edge configuration.

Example: app/page.tsx

export const runtime = 'nodejs'

export default function Page() {
  return <main>Runs on Node.js</main>
}

This page explicitly selects the default Node.js runtime.

When to use it

Configure a page

A page needs an explicit runtime declaration for clarity or configuration consistency.

Configure a route handler

A route handler should run with the standard server runtime.

Configure a layout

A layout governs runtime configuration for its route segment.

Interview questions

QWhat does the runtime export control?

runtime is a Route Segment Config export that selects the JavaScript runtime for rendering a route. It can be exported from a page, layout, or route handler, and 'nodejs' is the default.

Follow-up: What should a new application use if it does not need a different runtime? Use the default Node.js behavior and omit the export.

QWhich runtime values can be used?

The supported default is 'nodejs'. The documentation also lists 'edge', but explicitly marks the Edge Runtime as deprecated.

Follow-up: How should existing Edge usage be handled? Remove the runtime export from the route files when migrating away from Edge.

QWhere can runtime be declared?

A route segment can declare the setting directly with export const runtime = 'nodejs'. The same declaration can be placed in a layout or route handler.

Follow-up: Why might a layout-level declaration matter? The setting applies to the route segment represented by that layout and its configured descendants.

  • Route Segment Config
  • page
  • layout
  • Route Handler

Source: Route Segment Config: runtime - Next.js. Checked 2026-10-15.