agentleFS
vibestackdevvibestackdev/vibe-stack/.cursor/rules/nextjs15-params.mdc

vibe-stack / rules

Cursor rule8 starsChanged 8 months agoMITView on GitHub

Critical Next.js 15 breaking changes regarding async params and searchParams

The file

Files
nextjs15-params.mdc
---
description: Critical Next.js 15 breaking changes regarding async params and searchParams
globs: ["**/app/**/page.tsx", "**/app/**/layout.tsx", "**/app/**/route.ts"]
alwaysApply: false
---

# Next.js 15 Async Params (BREAKING CHANGE)

CRITICAL: In Next.js 15+, `params` and `searchParams` are ASYNC Promises.
This is a breaking change from Next.js 14. The AI MUST await them.

## Rule: Always Use Promise Types

✅ CORRECT (Next.js 15):
```tsx
type PageProps = { 
  params: Promise<{ slug: string }> 
  searchParams: Promise<{ [key: string]: string | string[] | undefined }> 
}

export default async function Page({ params, searchParams }: PageProps) {
  const { slug } = await params;
  const search = await searchParams;
}
```

❌ WRONG (outdated Next.js 14 pattern — will crash silently):
```tsx
// DO NOT GENERATE THIS PATTERN
export default function Page({ params }: { params: { slug: string } }) {
  const { slug } = params; // BREAKS: params is a Promise in Next.js 15
}
```

## Rule: generateMetadata Also Uses Async Params
```tsx
export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params;
  return { title: `Post: ${slug}` }
}
```

## Rule: Layout Components MUST Await Params
```tsx
export default async function Layout({
  children,
  params,
}: {
  children: React.ReactNode
  params: Promise<{ teamId: string }>
}) {
  const { teamId } = await params;
  return <div>{children}</div>
}
```

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.