This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
frontendcritical PriorityID: nextjs-15-ppr-dynamic-hole-isolation

Next.js 15 PPR Dynamic Hole Isolation and Static Shell Determinism

Enforces strict isolation of dynamic runtime operations inside localized React Suspense boundaries under Next.js 15 Partial Prerendering (PPR). Prevents dynamic bailouts (headers, cookies, searchParams, un-cached data queries) from leaking upward and de-optimizing edge-cacheable static shell generation into fully dynamic SSR passes. Guarantees deterministic Time-To-First-Byte (TTFB) at edge Points of Presence (POPs) by mandating non-dynamic layouts and strict dynamic hole sandboxing.

Prohibited Anti-Pattern: Unbounded Dynamic Access Leaking Across Layout Hierarchies Causing Static Shell De-optimization

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Next.js 15 PPR Dynamic Hole Isolation and Static Shell Determinism - Enforces strict isolation of dynamic runtime operations inside localized React Suspense boundaries under Next.js 15 Partial Prerendering (PPR). Prevents dynamic bailouts (headers, cookies, searchParams, un-cached data queries) from leaking upward and de-optimizing edge-cacheable static shell generation into fully dynamic SSR passes. Guarantees deterministic Time-To-First-Byte (TTFB) at edge Points of Presence (POPs) by mandating non-dynamic layouts and strict dynamic hole sandboxing.
globs: app/**/*.{ts,tsx}, src/app/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/nextjs-15-ppr-dynamic-hole-isolation"
---

# Next.js 15 PPR Dynamic Hole Isolation and Static Shell Determinism

> **Severity**: CRITICAL | **Category**: frontend
> **Anti-Pattern Warning**: Unbounded Dynamic Access Leaking Across Layout Hierarchies Causing Static Shell De-optimization

## System Constraints
You are a Principal Engineer enforcing Next.js 15 Partial Prerendering (PPR) Dynamic Hole Isolation. You must ensure that static shells remain purely deterministic and instantly cacheable at Edge POPs. Flag and remediate any un-sandboxed access to dynamic data sources (such as cookies(), headers(), searchParams, or non-cached database/network queries) in root layouts, page templates, or outer components that are not strictly isolated within local React <Suspense> boundaries with deterministic fallbacks.

## Strict Guidelines
- Engineers MUST ALWAYS isolate all dynamic functions (e.g., `cookies()`, `headers()`, `searchParams`, uncached I/O) inside dedicated leaf components wrapped with explicit `<Suspense fallback={<DeterministicSkeleton />}>` boundaries.
- Engineers MUST NEVER access dynamic Request APIs (`cookies()`, `headers()`, or un-cached async stores) in top-level `layout.tsx` or outside Suspense wrappers in `page.tsx`, as this converts the entire route subtree into dynamic SSR and destroys static shell pre-rendering.
- Root and intermediate `layout.tsx` files MUST remain fully deterministic and statically renderable at build time; dynamic session context MUST be deferred to isolated leaf client or server components.
- Engineers MUST export `export const experimental_ppr = true;` or configure `experimental: { ppr: 'incremental' }` in `next.config.ts`, validating dynamic boundary isolation with `@next/bundle-analyzer` or the Next.js build manifest.
- Fallback components within `<Suspense>` MUST NEVER execute dynamic operations or depend on server-side request state; fallbacks must be completely deterministic static markup.

## Bad vs Good Implementations
### Dynamic Request API Leak in Layout vs. Isolated Suspense Dynamic Hole

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Accessing `cookies()` at the layout level executes a dynamic bailout before any boundary is evaluated. The static shell cannot be generated at build/compile time or cached at edge POPs, forcing the entire HTML payload to fall back to blocking runtime SSR.
```typescript
import { cookies } from 'next/headers';
import { Suspense } from 'react';

// ANTI-PATTERN: Accessing cookies at layout or outer page level
// immediately bails the entire route out of static shell prerendering.
export default async function DashboardLayout({ children }: { children: React.ReactNode }) {
  const cookieStore = await cookies();
  const theme = cookieStore.get('theme')?.value ?? 'dark';

  return (
    <div className={`app-shell theme-${theme}`}>
      <header className="h-16 border-b">Dashboard</header>
      <main>{children}</main>
    </div>
  );
}
```

#### Production Standard (Correct)
> **Standard**: The layout remains fully static and is prerendered to an immutable edge-deliverable shell. Dynamic access via `cookies()` is isolated inside `UserSessionBadge` wrapped in a `<Suspense>` boundary, allowing edge POPs to serve the shell immediately while streaming the isolated dynamic hole.
```typescript
import { cookies } from 'next/headers';
import { Suspense } from 'react';

// DETERMINISTIC STATIC SHELL: Layout executes zero dynamic APIs.
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
  return (
    <div className="app-shell">
      <header className="h-16 border-b flex justify-between items-center px-4">
        <span>Dashboard</span>
        {/* Dynamic hole isolated behind Suspense */}
        <Suspense fallback={<div className="w-8 h-8 rounded-full bg-slate-200 animate-pulse" />}>
          <UserSessionBadge />
        </Suspense>
      </header>
      <main>{children}</main>
    </div>
  );
}

// ISOLATED DYNAMIC COMPONENT: Evaluated during edge streaming only.
async function UserSessionBadge() {
  const cookieStore = await cookies();
  const user = cookieStore.get('session_user')?.value ?? 'Guest';
  return <span className="font-medium text-sm">{user}</span>;
}
```

### Dynamic SearchParams Unwrapping vs. Suspense-Enclosed SearchParams Consumer

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Awaiting `searchParams` directly in the page component triggers dynamic evaluation for the entire page body, destroying the ability to deliver the surrounding static header, structure, and navigation from the POP edge cache instantly.
```typescript
// ANTI-PATTERN: Awaiting searchParams directly in page root bails out shell
interface PageProps {
  searchParams: Promise<{ query?: string }>;
}

export default async function SearchPage({ searchParams }: PageProps) {
  const resolvedParams = await searchParams;
  const query = resolvedParams.query ?? '';

  return (
    <div className="search-container">
      <h1>Search Catalog</h1>
      <p>Results for: {query}</p>
      {/* Catalog items */}
    </div>
  );
}
```

#### Production Standard (Correct)
> **Standard**: Passing the unresolved `searchParams` promise directly into a leaf component wrapped inside `<Suspense>` ensures the `SearchPage` shell remains prerenderable. Dynamic resolution only takes place inside the deferred stream hole.
```typescript
import { Suspense } from 'react';

interface PageProps {
  searchParams: Promise<{ query?: string }>;
}

export default function SearchPage({ searchParams }: PageProps) {
  return (
    <div className="search-container">
      <h1>Search Catalog</h1>
      {/* Static header and layout are preserved in the edge shell */}
      <Suspense fallback={<p className="animate-pulse text-muted">Loading query...</p>}>
        <SearchResults searchParams={searchParams} />
      </Suspense>
    </div>
  );
}

async function SearchResults({ searchParams }: { searchParams: Promise<{ query?: string }> }) {
  const resolved = await searchParams;
  const query = resolved.query ?? '';
  return <p>Results for: {query}</p>;
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Next.js 15 PPR Dynamic Hole Isolation and Static Shell Determinism

Next.js 15 PPR Dynamic Hole Isolation and Static Shell Determinism defines an industrial-grade behavioral standard for frontend engineering. Enforces strict isolation of dynamic runtime operations inside localized React Suspense boundaries under Next.js 15 Partial Prerendering (PPR). Prevents dynamic bailouts (headers, cookies, searchParams, un-cached data queries) from leaking upward and de-optimizing edge-cacheable static shell generation into fully dynamic SSR passes. Guarantees deterministic Time-To-First-Byte (TTFB) at edge Points of Presence (POPs) by mandating non-dynamic layouts and strict dynamic hole sandboxing. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Unbounded Dynamic Access Leaking Across Layout Hierarchies Causing Static Shell De-optimization Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftUnbounded Dynamic Access Leaking Across Layout Hierarchies Causing Static Shell De-optimizationCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS isolate all dynamic functions (e.g., `cookies()`, `headers()`, `searchParams`, uncached I/O) inside dedicated leaf components wrapped with explicit `<Suspense fallback={<DeterministicSkeleton />}>` boundaries.

Engineers MUST ALWAYS isolate all dynamic functions (e.g., `cookies()`, `headers()`, `searchParams`, uncached I/O) inside dedicated leaf components wrapped with explicit `<Suspense fallback={<DeterministicSkeleton />}>` boundaries.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST NEVER access dynamic Request APIs (`cookies()`, `headers()`, or un-cached async stores) in top-level `layout.tsx` or outside Suspense wrappers in `page.tsx`, as this converts the entire route subtree into dynamic SSR and destroys static shell pre-rendering.

Engineers MUST NEVER access dynamic Request APIs (`cookies()`, `headers()`, or un-cached async stores) in top-level `layout.tsx` or outside Suspense wrappers in `page.tsx`, as this converts the entire route subtree into dynamic SSR and destroys static shell pre-rendering.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Root and intermediate `layout.tsx` files MUST remain fully deterministic and statically renderable at build time

Root and intermediate `layout.tsx` files MUST remain fully deterministic and statically renderable at build time; dynamic session context MUST be deferred to isolated leaf client or server components.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Engineers MUST export `export const experimental_ppr = true

Engineers MUST export `export const experimental_ppr = true;` or configure `experimental: { ppr: 'incremental' }` in `next.config.ts`, validating dynamic boundary isolation with `@next/bundle-analyzer` or the Next.js build manifest.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Fallback components within `<Suspense>` MUST NEVER execute dynamic operations or depend on server-side request state

Fallback components within `<Suspense>` MUST NEVER execute dynamic operations or depend on server-side request state; fallbacks must be completely deterministic static markup.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Next.js 15 PPR Dynamic Hole Isolation and Static Shell Determinism critical for AI coding assistants?

Enforces strict isolation of dynamic runtime operations inside localized React Suspense boundaries under Next.js 15 Partial Prerendering (PPR). Prevents dynamic bailouts (headers, cookies, searchParams, un-cached data queries) from leaking upward and de-optimizing edge-cacheable static shell generation into fully dynamic SSR passes. Guarantees deterministic Time-To-First-Byte (TTFB) at edge Points of Presence (POPs) by mandating non-dynamic layouts and strict dynamic hole sandboxing. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Unbounded Dynamic Access Leaking Across Layout Hierarchies Causing Static Shell De-optimization) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

Related FRONTEND Rules

View all rules →
frontend
119

SolidStart 1.0 Server Functions & Async Boundaries Production Standard

SolidStart 1.0 relies on the Vinxi bundler to split `server$` closures into independent HTTP POST RPC endpoints. Direct lexical closure over client signals within `server$` scopes or failure to demarcate async boundaries with `<Suspense>` causes silent serialization failures, client-bundle secret leaks, and SSR hydration mismatches. Enforcing strict parameter passing, runtime input validation, and Solid async primitives maintains security and fine-grained reactivity across network boundaries.

frontend
119

Astro 5 Actions & Content Layer Production Standard

Enforces strict type safety and architectural correctness for Astro 5 Server Actions and the zero-waterfall Content Layer API. Prevents runtime contract mismatches, hydration mismatches, and unhandled mutation exceptions across dynamic and prerendered boundaries. Failure to follow these patterns leads to silent data fetching waterfalls, build-time cache corruptions, and unhandled server action exceptions.

frontend
51

Nuxt 4 Nitro Server Engine & Shared Directory Production Standard

Nuxt 4 enforces strict boundary segregation between client UI in the app/ directory, backend endpoints in server/, and universal contracts in shared/. Violating cross-boundary isolation or maintaining module-scoped state in Nitro server handlers causes catastrophic cross-request data corruption and hydration mismatches under concurrent production traffic. Architects must enforce request-isolated H3 event contexts, universal serialization schemas, and strict path-alias boundaries.

1 Rule in Stack

Next.js