Instruction file imported from Timothy191/Arch-System (
.cursor/rules/002-nextjs-boundaries.mdc). Copyright stays with the author.
Next.js 16 App Router & RSC Boundary Invariants
Hard Invariants:
- Server Components by Default: Layouts and pages MUST be React Server Components (no directive).
- Leaf Client Interactivity: Only push
'use client'down to the smallest interactive leaf components. - Zero Direct DB Access in Client Components: Client components must NEVER import
@repo/supabase/serveror query the database directly. Use props, streamed promises withuse(promise), or typed API route handlers (/api/...). - Zero Waterfall: Independent data requests in RSC must be parallelized with
Promise.allSettled()orPromise.all(). Wrap per-request lookups inReact.cache(). - Dynamic API Isolation: Dynamic request APIs (
cookies(),headers()) must be isolated behind<Suspense>boundaries to preserve static prerendering of the App Shell. - Images: Always use
<Image />fromnext/imagewith explicitwidth/heightorfillwithsizes. Never use raw<img>.
