Type something to search...
Next.js Route Segment Config

Next.js Route Segment Config

Behind the friendly file conventions of the App Router — page.js, layout.js, route.js — sits a small set of plain exported variables that let you override specific rendering behaviors for that one segment: which runtime it executes in, how long it's allowed to run, whether unlisted dynamic params should even be attempted. Collectively, these are the Route Segment Config options, and this article is the map to the individual, dedicated references covering each one in depth.

How It Works

Every option in this family is just a named export from page.js, layout.js, or route.js — no special syntax, no wrapper function, just a constant:

export const runtime = "nodejs";
export const maxDuration = 30;

Next.js recognizes these specific export names at build time and adjusts the segment's behavior accordingly. You opt in only to the ones you actually need to override; every option has a sensible default that applies if you don't export it at all.

The Current Option Set

OptionTypeDefault
dynamicParamsbooleantrue
runtime'nodejs' | 'edge' (edge deprecated)'nodejs'
preferredRegion'auto' | 'global' | 'home' | string | string[] (deprecated)'auto'
maxDurationnumberSet by your deployment platform

Alongside these four, two more options round out the current set: instant (controlling instant-navigation behavior) and prefetch (controlling prefetch behavior for a segment) — both are covered in their own dedicated references, since each has enough nuance to warrant a full article rather than a single table row.

A Meaningful Recent Change: Options That No Longer Exist Here

If you're coming from an older Next.js codebase, or reading older tutorials, you'll likely encounter route segment config options that aren't in this current list at all: dynamic, revalidate, and fetchCache. This isn't an oversight in this reference — as of a recent major version, these three options are removed entirely once Cache Components is enabled, because the caching model they controlled has been replaced by the newer use cache directive-based system.

If your project has Cache Components enabled and you're still exporting export const revalidate = 60 expecting it to do something, it won't — that entire configuration surface belongs to the previous caching model, documented separately as "Caching and Revalidating (Previous Model)" for projects that haven't adopted Cache Components yet. Migrating a route that still uses these older exports means moving to the use cache directive and cacheLife/cacheTag instead, not simply carrying the old exports forward unchanged.

A second, related removal worth flagging if you're maintaining an older codebase: export const experimental_ppr = true was also removed as of the same version. A dedicated codemod exists specifically to strip this now-meaningless export from your Pages and Layouts automatically, rather than requiring a manual find-and-remove across your whole codebase.

A Deprecation Worth Tracking If You're on Edge Runtime

export const runtime = "experimental-edge" — the older string value for opting a segment into the Edge runtime — was deprecated as of Next.js 15. A codemod exists to transform this value to the current, non-experimental "edge" string automatically. If your codebase predates this change and still has experimental-edge scattered across route files, running that codemod is the recommended path rather than hand-editing every occurrence.

The Individual References

Each option below has genuinely distinct enough behavior, edge cases, and defaults to warrant its own dedicated article rather than a shared page:

OptionWhat it controls
dynamicParamsWhether requests for dynamic segments not returned by generateStaticParams are still handled, or 404 immediately
instantInstant-navigation behavior for a segment
maxDurationThe maximum execution time allowed for a segment's server-side work
preferredRegion (deprecated)Which deployment region a segment prefers to execute in
prefetchPrefetch behavior for a segment's links
runtimeWhether a segment executes in the Node.js or Edge runtime

Version History

VersionChange
v16.0.0dynamic, dynamicParams, revalidate, and fetchCache removed when Cache Components is enabled — see the Previous Model caching guide for the older, still-supported alternative
v16.0.0export const experimental_ppr = true removed; a codemod is available
v15.0.0-RCexport const runtime = "experimental-edge" deprecated; a codemod is available

Key Takeaways

ConceptDetail
MechanismPlain named exports from page.js, layout.js, or route.js — no special syntax
Current core optionsdynamicParams, runtime, preferredRegion, maxDuration, plus instant and prefetch
Removed under Cache Componentsdynamic, revalidate, fetchCache — replaced by use cache, cacheLife, and cacheTag
experimental_pprRemoved entirely; a codemod cleans it up automatically
runtime value migration"experimental-edge""edge", via codemod

The single most important thing to take from this overview, if you're working in a codebase that predates Cache Components, is that route segment config isn't a static, fixed API — three of its most commonly used options were deliberately retired as the caching model evolved. Before reaching for revalidate or fetchCache in new code, confirm which caching model your project is actually on; using the wrong generation's options silently does nothing rather than raising a helpful error.

Tags :
Share :

Related Posts

Can Next.js Be Used with GraphQL?

Can Next.js Be Used with GraphQL?

Next.js and GraphQL are two powerful technologies that have gained significant traction in the web development community. Next.js, a React-based fram

Dive Deeper
How does Next.js differ from Create React App?

How does Next.js differ from Create React App?

In the world of modern web development, React.js has emerged as a dominant force due to its flexibility, performance, and extensive ecosystem. Two po

Dive Deeper
How does Next.js handle image optimization?

How does Next.js handle image optimization?

In modern web development, image optimization plays a critical role in enhancing user experience and improving site performance. Large, unoptimized i

Dive Deeper