Windsurf rules for Next.js 15/16 App Router: Server Components by default, async params, file conventions including proxy, and validated Server Functions with revalidation.
.devin/rules/nextjs-app-router-for-windsurf.md. Downloaded files need to be placed in that repository path.---
trigger: glob
globs: "**/*"
---
Apply these rules to Next.js App Router code. Check the `next` version in package.json; this targets Next.js 15 and 16.
## Server Components by default
- Components in `app/` are Server Components unless the file starts with `'use client'`. Add it only for state, effects, event handlers or browser APIs, and keep those components small.
- Fetch data directly in Server Components; pass only serializable props to Client Components.
## File conventions
```
app/
├── layout.tsx # root layout (required)
├── page.tsx # home page
├── loading.tsx # streaming fallback for the segment
├── error.tsx # error boundary ('use client' required)
├── not-found.tsx
├── (auth)/ # route group: no URL segment
│ ├── login/page.tsx
│ └── signup/page.tsx
└── api/
└── health/route.ts # route handler
proxy.ts # Next.js 16 name for middleware.ts
```
## Data fetching
```tsx
// app/products/[id]/page.tsx
import { notFound } from 'next/navigation';
import { getProduct } from '@/lib/products';
import { AddToCart } from './add-to-cart'; // Client Component
export default async function ProductPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params; // params is a Promise in Next.js 15+
const product = await getProduct(id);
if (!product) notFound();
return (
<div>
<h1>{product.name}</h1>
<AddToCart id={product.id} />
</div>
);
}
```
- `fetch` is not cached by default in Next.js 15+. Cache deliberately (`'use cache'` with Cache Components in 16, or the options documented for your version).
## Server Functions
```ts
'use server';
import { revalidatePath } from 'next/cache';
import { db } from '@/lib/db';
import { getSession } from '@/lib/auth';
export async function createPost(formData: FormData) {
const session = await getSession();
if (!session) throw new Error('Unauthorized');
const title = formData.get('title');
if (typeof title !== 'string' || title.trim().length === 0) {
return { error: 'Title is required' };
}
await db.post.create({ data: { title: title.trim(), authorId: session.userId } });
revalidatePath('/posts');
return { ok: true };
}
```
- `formData.get` returns `string | File | null`; check it before use. Server Functions can be called directly by POST, so check auth and input in each one.
Cursor rules for Next.js 14+ App Router projects updated for Next.js 16 with async params, validated Route Handlers, generateMetadata and proxy.ts in place of middleware.
CLAUDE.md rules for the Next.js 16 App Router with async params, streaming via Suspense, secured Server Actions, metadata conventions and explicit caching choices.
Copilot instructions for Next.js App Router code with awaited params, authenticated Server Actions, typed Route Handlers and explicit caching.
Windsurf
fullstack
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
A Next.js 16 project in Windsurf has pages typed as { params: { id: string } }, a createPost action that writes formData.get('title') unchecked, and a middleware.ts file.
Update app/products/[id]/page.tsx, app/posts/actions.ts and the middleware for Next.js 16 using the Next.js App Router rule.
Pages typed with params: Promise<...> and awaited, notFound() for missing records, createPost checking session and title type before writing and importing revalidatePath, and middleware.ts renamed to proxy.ts with the export renamed as the Next 16 migration guide describes.
Windsurf's rules documentation (docs.windsurf.com/windsurf/cascade/memories) now redirects to Devin documentation, which describes rules for the Devin Local agent in Devin Desktop. Current rules live in .devin/rules/*.md with a trigger setting, and the legacy Windsurf files (.windsurf/rules/*.md, .windsurf/global_rules.md and .windsurfrules) are still imported by default. AGENTS.md files are read as always-on rules.
.devin/rules/nextjs-app-router-for-windsurf.mdStarting point, not a tested configuration for your repository. Applied when files matching globs are involved (trigger: glob). Review the instructions, adapt the file paths and run your project's existing checks.
---
trigger: glob
globs: "**/*"
---
Apply these rules to Next.js App Router code. Check the `next` version in package.json; this targets Next.js 15 and 16.
## Server Components by default
- Components in `app/` are Server Components unless the file starts with `'use client'`. Add it only for state, effects, event handlers or browser APIs, and keep those components small.
- Fetch data directly in Server Components; pass only serializable props to Client Components.
## File conventions
```
app/
├── layout.tsx # root layout (required)
├── page.tsx # home page
├── loading.tsx # streaming fallback for the segment
├── error.tsx # error boundary ('use client' required)
├── not-found.tsx
├── (auth)/ # route group: no URL segment
│ ├── login/page.tsx
│ └── signup/page.tsx
└── api/
└── health/route.ts # route handler
proxy.ts # Next.js 16 name for middleware.ts
```
## Data fetching
```tsx
// app/products/[id]/page.tsx
import { notFound } from 'next/navigation';
import { getProduct } from '@/lib/products';
import { AddToCart } from './add-to-cart'; // Client Component
export default async function ProductPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params; // params is a Promise in Next.js 15+
const product = await getProduct(id);
if (!product) notFound();
return (
<div>
<h1>{product.name}</h1>
<AddToCart id={product.id} />
</div>
);
}
```
- `fetch` is not cached by default in Next.js 15+. Cache deliberately (`'use cache'` with Cache Components in 16, or the options documented for your version).
## Server Functions
```ts
'use server';
import { revalidatePath } from 'next/cache';
import { db } from '@/lib/db';
import { getSession } from '@/lib/auth';
export async function createPost(formData: FormData) {
const session = await getSession();
if (!session) throw new Error('Unauthorized');
const title = formData.get('title');
if (typeof title !== 'string' || title.trim().length === 0) {
return { error: 'Title is required' };
}
await db.post.create({ data: { title: title.trim(), authorId: session.userId } });
revalidatePath('/posts');
return { ok: true };
}
```
- `formData.get` returns `string | File | null`; check it before use. Server Functions can be called directly by POST, so check auth and input in each one.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
The docs recommend keeping rules short and specific. The current docs say AGENTS.md, AGENTS.local.md and AGENT.md are read as always-on rules, including files in subdirectories. Use .devin/rules/ when you need glob, model-decision or manual triggers.
Documentation checked 2026-11-05: Devin docs: Local customizations (redirect target of Windsurf memories docs)Windsurf docs: Cascade memories (redirects)
Cursor rules for Next.js 14+ App Router projects updated for Next.js 16 with async params, validated Route Handlers, generateMetadata and proxy.ts in place of middleware.
CLAUDE.md rules for the Next.js 16 App Router with async params, streaming via Suspense, secured Server Actions, metadata conventions and explicit caching choices.
Copilot instructions for Next.js App Router code with awaited params, authenticated Server Actions, typed Route Handlers and explicit caching.