liveBook · Manning

Route segment configuration

As explained in Build AI-Enhanced Web Apps

A Next.js configuration that controls the rendering and runtime behavior of an individual route segment.

Route segment configuration controls caching, rendering mode, and execution limits for an individual Next.js App Router segment. Streaming requires caching to be disabled. section 8.1.1

Configure streaming routes with settings that match the deployment environment:

  • Set dynamic to 'force-dynamic' to force dynamic rendering. section 8.1.1
  • Set maxDuration to limit streaming responses to a defined runtime, such as 30 seconds. section 8.1.1
  • Call unstable_noStore from next/cache when component-level cache opt-out is needed for fresh data. section 8.1.1

Force dynamic streaming

Add configuration at the top of the page component for the route segment:\n\nexport const dynamic = 'force-dynamic';\nexport const maxDuration = 30; section 8.1.1

// Force the page to be dynamic and allow 
// streaming responses up to 30 seconds
export const dynamic = 'force-dynamic'; 
export const maxDuration = 30;

View the compact route-segment configuration used to enable dynamic rendering and allow streaming responses for up to 30 seconds. section 8.1.1

How Build AI-Enhanced Web Apps covers it

How deep it goes
Shows route-level flags and component-level cache opt-out, while deferring provider-specific deployment behavior.
Examples
Uses dynamic='force-dynamic', maxDuration=30, and unstable_noStore in a streamed page or component.
What you can do after
Operate/configure streamed Next.js routes to force dynamic rendering, limit duration, and bypass component-level caching.
How it connects
Connects dynamic rendering with caching, streaming responses, component-level data freshness, and deployment providers.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI-Enhanced Web Apps. The section links point to the parts of the book it draws on.