npx agentspec-cli install c37cff09-0d3e-438b-97e3-cba0817a4705 --file-type cursor-rules→ .cursor/rules/
---
description: Next.js 16 App Router Server Components and Boundary Invariants
globs: apps/portal/app/**/*.{ts,tsx},apps/portal/features/**/*.{ts,tsx}
alwaysApply: false
---
# Next.js 16 App Router & RSC Boundary Invariants
### Hard Invariants:
1. **Server Components by Default**: Layouts and pages MUST be React Server Components (no directive).
2. **Leaf Client Interactivity**: Only push `'use client'` down to the smallest interactive leaf components.
3. **Zero Direct DB Access in Client Components**: Client components must NEVER import `@repo/supabase/server` or query the database directly. Use props, streamed promises with `use(promise)`, or typed API route handlers (`/api/...`).
4. **Zero Waterfall**: Independent data requests in RSC must be parallelized with `Promise.allSettled()` or `Promise.all()`. Wrap per-request lookups in `React.cache()`.
5. **Dynamic API Isolation**: Dynamic request APIs (`cookies()`, `headers()`) must be isolated behind `<Suspense>` boundaries to preserve static prerendering of the App Shell.
6. **Images**: Always use `<Image />` from `next/image` with explicit `width`/`height` or `fill` with `sizes`. Never use raw `<img>`.
spnextjs
Implement Next.js App Router frontend with server components by default, handle authentication state, and ensure all data access goes through API client.
by AgentHub Crawler
Next.js 16/React 19 Architecture Rules
1. **NO `middleware.ts` ALLOWED:** As of Next.js 16+, the standard edge router interceptor must NEVER be named `middleware.ts`. It has been formally deprecated. You MUST write interception logic inside `src/proxy.ts` (or `proxy.ts`). If you generate a `middleware.ts` it will crash the Turbopack dev server and compilation due to file convention errors.
by AgentHub Crawler
next-cache-components
Next.js 16 Cache Components - PPR, use cache directive, cacheLife, cacheTag, updateTag
by AgentHub Crawler
Sign in to leave a comment.
nextjs-mastery
Next.js 14+ App Router patterns including RSC, ISR, middleware, parallel routes, and data fetching
by AgentHub Crawler