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-hydration-guardrail

Next.js 15 PPR Dynamic Hole Hydration & Latency Boundary Guardrail

Enforces strict isolation of dynamic runtime primitives within React Suspense boundaries paired with dimensionally-locked micro-skeletons for Next.js 15 Partial Prerendering (PPR). Prevents dynamic stream queries from blocking the static pre-rendered edge shell or inducing Cumulative Layout Shift (CLS) cascades upon hydration. Mandates strict latency timeouts on async dynamic holes to safeguard Time to First Byte (TTFB) and stream completion.

Prohibited Anti-Pattern: Top-Level Dynamic Accessors and Naked Suspense Holes De-optimizing Static Edge Shells and Triggering Hydration Shifts

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Next.js 15 PPR Dynamic Hole Hydration & Latency Boundary Guardrail - Enforces strict isolation of dynamic runtime primitives within React Suspense boundaries paired with dimensionally-locked micro-skeletons for Next.js 15 Partial Prerendering (PPR). Prevents dynamic stream queries from blocking the static pre-rendered edge shell or inducing Cumulative Layout Shift (CLS) cascades upon hydration. Mandates strict latency timeouts on async dynamic holes to safeguard Time to First Byte (TTFB) and stream completion.
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-hydration-guardrail"
---

# Next.js 15 PPR Dynamic Hole Hydration & Latency Boundary Guardrail

> **Severity**: CRITICAL | **Category**: frontend
> **Anti-Pattern Warning**: Top-Level Dynamic Accessors and Naked Suspense Holes De-optimizing Static Edge Shells and Triggering Hydration Shifts

## System Constraints
You are a Principal Software Architect enforcing Next.js 15 Partial Prerendering (PPR) Dynamic Hole Hydration Guardrails. You must mandate strict structural boundaries separating static edge shells from dynamic streaming components. Every dynamic primitive (e.g., cookies, headers, dynamic params, uncached fetches) must be encapsulated in a localized, dimensionally-stable React Suspense boundary with deterministic micro-skeletons and strict promise timeouts.

## Strict Guidelines
- Engineers MUST ALWAYS isolate dynamic runtime primitives (`cookies()`, `headers()`, `searchParams`, uncached `fetch()`) into discrete leaf React Server Components (RSC) wrapped in a `<Suspense>` boundary.
- Engineers MUST NOT invoke dynamic runtime functions directly in root Layouts or Page components without immediate Suspense encapsulation, as this de-optimizes the entire route shell into dynamic runtime rendering.
- Components MUST provide micro-skeleton fallbacks matching the exact box-model dimensions (`min-height`, `aspect-ratio`, grid/flex alignment) of the hydrated component to ensure zero Cumulative Layout Shift (CLS).
- Dynamic data fetchers MUST enforce strict latency boundaries using `AbortSignal.timeout()` or race-condition timeouts to prevent hung downstream APIs from holding dynamic stream connections open indefinitely.
- Routes leveraging PPR MUST explicitly export `export const experimental_ppr = true;` (or `'incremental'`) to enable static pre-render analysis and edge-shell caching at build time.
- Engineers MUST NEVER use arbitrary layout-shifting generic fallbacks such as `<div>Loading...</div>` or empty fragments within dynamic PPR holes.

## Bad vs Good Implementations
### Isolating Dynamic User Profile Stream in Next.js 15 PPR

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Invoking `await cookies()` and un-isolated fetching at the page level forces the entire page—including the static shell—to render dynamically at runtime. The fallback lacks explicit dimensions, triggering severe Cumulative Layout Shift (CLS) when hydrated.
```typescript
import { cookies } from 'next/headers';
import { Suspense } from 'react';

// ANTI-PATTERN: Dynamic accessor invoked at page root bails out static prerendering.
// Generic fallback has no height or width constraints, causing massive CLS.
export default async function DashboardPage() {
  const cookieStore = await cookies();
  const token = cookieStore.get('auth_token')?.value;
  const user = await fetch('https://api.internal/user', {
    headers: { Authorization: `Bearer ${token}` }
  }).then((r) => r.json());

  return (
    <div className="flex flex-col gap-4 p-8">
      <header className="border-b pb-4">
        <h1>Static Shell Dashboard</h1>
      </header>
      <Suspense fallback={<div>Loading...</div>}>
        <div className="p-4 bg-gray-50 rounded-lg">
          <h2>Welcome, {user.name}</h2>
          <p>{user.email}</p>
        </div>
      </Suspense>
    </div>
  );
}
```

#### Production Standard (Correct)
> **Standard**: The static edge shell (header, layout) prerenders completely at build/deploy time. Dynamic data fetching and cookie access are strictly encapsulated in `DynamicUserCard`. The `UserCardSkeleton` establishes deterministic min-height constraints preventing CLS, while `AbortSignal.timeout(1500)` prevents slow dynamic fetches from delaying stream completion.
```typescript
import { Suspense } from 'react';
import { cookies } from 'next/headers';

export const experimental_ppr = true;

// DETERMINISTIC MICRO-SKELETON: Matches hydrated layout dimensions exactly
function UserCardSkeleton() {
  return (
    <div
      aria-hidden="true"
      className="min-h-[88px] w-full animate-pulse rounded-lg bg-gray-100 p-4 border border-gray-200"
    >
      <div className="h-5 w-48 rounded bg-gray-300" />
      <div className="mt-2 h-4 w-32 rounded bg-gray-200" />
    </div>
  );
}

// DYNAMIC HOLE COMPONENT: Isolated async leaf RSC
async function DynamicUserCard() {
  const cookieStore = await cookies();
  const token = cookieStore.get('auth_token')?.value;

  if (!token) {
    return (
      <div className="min-h-[88px] w-full rounded-lg bg-gray-50 p-4 border border-gray-200">
        <p className="text-sm text-gray-500">Guest Session</p>
      </div>
    );
  }

  // Strict latency budget: 1500ms timeout prevents stream stalling
  const response = await fetch('https://api.internal/user', {
    headers: { Authorization: `Bearer ${token}` },
    cache: 'no-store',
    signal: AbortSignal.timeout(1500)
  }).catch(() => null);

  const user = response?.ok ? await response.json() : null;

  return (
    <div className="min-h-[88px] w-full rounded-lg bg-gray-50 p-4 border border-gray-200">
      <h2 className="text-base font-semibold text-gray-900">
        Welcome, {user?.name ?? 'Valued User'}
      </h2>
      <p className="text-sm text-gray-600">{user?.email ?? 'No email on record'}</p>
    </div>
  );
}

// STATIC PRE-RENDERED EDGE SHELL
export default function DashboardPage() {
  return (
    <div className="flex flex-col gap-4 p-8">
      <header className="border-b pb-4">
        <h1 className="text-xl font-bold">Static Shell Dashboard</h1>
      </header>
      <Suspense fallback={<UserCardSkeleton />}>
        <DynamicUserCard />
      </Suspense>
    </div>
  );
}
```

Recommended MCP Servers (mcp-serverlist.com)

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

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Next.js 15 PPR Dynamic Hole Hydration & Latency Boundary Guardrail

Next.js 15 PPR Dynamic Hole Hydration & Latency Boundary Guardrail defines an industrial-grade behavioral standard for frontend engineering. Enforces strict isolation of dynamic runtime primitives within React Suspense boundaries paired with dimensionally-locked micro-skeletons for Next.js 15 Partial Prerendering (PPR). Prevents dynamic stream queries from blocking the static pre-rendered edge shell or inducing Cumulative Layout Shift (CLS) cascades upon hydration. Mandates strict latency timeouts on async dynamic holes to safeguard Time to First Byte (TTFB) and stream completion. 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: Top-Level Dynamic Accessors and Naked Suspense Holes De-optimizing Static Edge Shells and Triggering Hydration Shifts 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 DriftTop-Level Dynamic Accessors and Naked Suspense Holes De-optimizing Static Edge Shells and Triggering Hydration ShiftsCritical
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 dynamic runtime primitives (`cookies()`, `headers()`, `searchParams`, uncached `fetch()`) into discrete leaf React Server Components (RSC) wrapped in a `<Suspense>` boundary.

Engineers MUST ALWAYS isolate dynamic runtime primitives (`cookies()`, `headers()`, `searchParams`, uncached `fetch()`) into discrete leaf React Server Components (RSC) wrapped in a `<Suspense>` boundary.

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 NOT invoke dynamic runtime functions directly in root Layouts or Page components without immediate Suspense encapsulation, as this de-optimizes the entire route shell into dynamic runtime rendering.

Engineers MUST NOT invoke dynamic runtime functions directly in root Layouts or Page components without immediate Suspense encapsulation, as this de-optimizes the entire route shell into dynamic runtime 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

Components MUST provide micro-skeleton fallbacks matching the exact box-model dimensions (`min-height`, `aspect-ratio`, grid/flex alignment) of the hydrated component to ensure zero Cumulative Layout Shift (CLS).

Components MUST provide micro-skeleton fallbacks matching the exact box-model dimensions (`min-height`, `aspect-ratio`, grid/flex alignment) of the hydrated component to ensure zero Cumulative Layout Shift (CLS).

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

Dynamic data fetchers MUST enforce strict latency boundaries using `AbortSignal.timeout()` or race-condition timeouts to prevent hung downstream APIs from holding dynamic stream connections open indefinitely.

Dynamic data fetchers MUST enforce strict latency boundaries using `AbortSignal.timeout()` or race-condition timeouts to prevent hung downstream APIs from holding dynamic stream connections open indefinitely.

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

Routes leveraging PPR MUST explicitly export `export const experimental_ppr = true

Routes leveraging PPR MUST explicitly export `export const experimental_ppr = true;` (or `'incremental'`) to enable static pre-render analysis and edge-shell caching at build time.

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.
6

Engineers MUST NEVER use arbitrary layout-shifting generic fallbacks such as `<div>Loading...</div>` or empty fragments within dynamic PPR holes.

Engineers MUST NEVER use arbitrary layout-shifting generic fallbacks such as `<div>Loading...</div>` or empty fragments within dynamic PPR holes.

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 Hydration & Latency Boundary Guardrail critical for AI coding assistants?

Enforces strict isolation of dynamic runtime primitives within React Suspense boundaries paired with dimensionally-locked micro-skeletons for Next.js 15 Partial Prerendering (PPR). Prevents dynamic stream queries from blocking the static pre-rendered edge shell or inducing Cumulative Layout Shift (CLS) cascades upon hydration. Mandates strict latency timeouts on async dynamic holes to safeguard Time to First Byte (TTFB) and stream completion. 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 (Top-Level Dynamic Accessors and Naked Suspense Holes De-optimizing Static Edge Shells and Triggering Hydration Shifts) 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