Cursor Rules: Next.js 15 App Router & Strict Server Actions
Enforce strict React 19 Server Components, safe Server Action mutations, Zod schema validation, and Partial Prerendering (PPR) in Cursor.
Parametric Customizer & Compiler Live Tool
Adjust the variables below. The prompt code and API payload update dynamically in real time.
Feature being built in Next.js
# .cursorrules - Next.js 15 & React 19 Production Guidelines
You are a Principal Fullstack React/Next.js Engineer. When writing code, generating refactors, or creating routes for this project, strictly enforce the following invariants:
### 1. SERVER-FIRST BY DEFAULT
- Every component in `app/` is a React Server Component (RSC) by default. NEVER add `'use client'` unless the component strictly requires `useState`, `useEffect`, `useRef`, or browser DOM event listeners.
- Push `'use client'` to the outermost leaf nodes of the component tree to maximize server-side rendering and streaming.
### 2. SERVER ACTIONS HYGIENE ('use server')
- All Server Actions must reside in dedicated `actions/` files or export functions explicitly marked with `'use server'`.
- **Input Validation**: NEVER trust raw client arguments. Every Server Action must validate inputs using a strict Zod schema before executing database queries.
- **Authentication & RBAC**: Every action must verify session authentication (`const session = await auth()`) and authorization permissions before execution.
- **Return Signatures**: Return standardized result objects: `{ success: true, data }` or `{ success: false, error: string }`. NEVER throw unhandled exceptions to the client.
### 3. DATA FETCHING & CACHE MANAGEMENT
- Fetch data directly in Server Components using async/await and native `fetch` with Next.js 15 `cache: 'no-store'` or `next: { tags: ['...'], revalidate: 3600 }`.
- Use `revalidatePath()` or `revalidateTag()` inside Server Actions to purge stale cache after mutations.
### 4. MODERN REACT 19 HOOKS
- Use `useActionState` and `useFormStatus` instead of legacy manual loading state booleans.
- Use `useOptimistic` for instantaneous UI updates before server confirmation.
Target Domain Feature:
{Multi-Tenant Workspace Invitation & Role Management Dashboard}
Database & Auth Stack:
{PostgreSQL with Drizzle ORM & Auth.js v5 (NextAuth)} Supercharge Next.js 15 and React 19 development with strict production .cursorrules.
Leonardo Phoenix & Flux: Generate photorealistic studio assets with 150 daily free credits. Zero setup required.
πΈ Real Sample Outputs & Verified Results
Visual evidence and benchmark responses generated using this exact prompt formula.
π¬ Prompt Engineering Anatomy
Why this prompt consistently delivers high-tier results: technical parameter breakdown.
Server Action Input Guard Guarantees that untrusted client payloads cannot trigger SQL injection, role privilege escalation, or corrupted database states.
React 19 useActionState Hook Replaces boilerplate useState/useEffect form handlers with native React 19 form actions and pending states.
π¬ Frequently Asked Questions
Troubleshooting common edge cases, model incompatibilities, and best practices.
How do I install these rules in Cursor?
Copy this entire prompt into a file named .cursorrules at the root of your Next.js project directory.
Is this updated for Next.js 15 and React 19?
Yes, it specifically enforces Next.js 15 async Request APIs (cookies, headers, params) and React 19 useActionState primitives.
Cursor AI & Claude 3.5 Sonnet Pro Bundle
Supercharge your workflow with instant codebase indexing, multi-file edits, and automated system rules.
Explore Related Coding & Architecture Prompts View all β
Claude 3.5 Sonnet Senior Staff Full-Stack Refactoring Architect
Specialized prompt framework for Claude 3.5 Sonnet and Claude 3.7. Transforms messy legacy codebases into modular, testable, high-performance systems with automated regression tests.
cursorCursor AI (.cursorrules) for Next.js 15, React 19 & Tailwind CSS
Stops Cursor from writing outdated Next.js 13 patterns, Pages Router syntax, or deprecated React hooks. Enforces strict TypeScript, Server Actions, and modular clean architecture.
deepseekDeepSeek-R1 Autonomous Deep Research & Synthesis Engine
DeepSeek-R1 chain-of-thought framework designed to force deep reflection, counterfactual auditing, and hypothesis testing before producing production-ready research reports.