工作台模板

Next.js App Router / RSC:.cursor/rules/app-router.mdc 与 rsc.mdc

用 Next.js App Router(app/ 或 src/app/)的 Cursor 用户。路径:.cursor/rules/app-router.mdc · .cursor/rules/rsc.mdc

不是 Roo / Cline 模版。本站不托管安装包。订哪档去 /compare。

全部工作台模板 · 官方安装 · 订哪档

把下面两个 .mdc 放到仓库根.cursor/rules/。这是 Cursor Project Rules 路径,不是 Roo 的 .roo,也不是 Cline 的 .clinerules

规则投进仓库之后,再去 /compare 对照 Pro / Business / 自备 Key。本站不托管安装包,桌面 IDE 走 /downloads

.cursor/rules/app-router.mdc
.cursor/rules/app-router.mdc
---
description: Next.js App Router routing, layouts, metadata, and route files
globs: "{app,src/app}/**/*.{ts,tsx,js,jsx}"
alwaysApply: false
---

# App Router

- Routes live under `app/` or `src/app/`. Do not add `pages/` or `getServerSideProps` / `getStaticProps`.
- `layout.tsx` wraps a segment; `page.tsx` is the leaf. Keep the unique `<h1>` in `page.tsx` (or the leaf that owns the document title story), not in a shared layout that would collide across URLs.
- Colocate `loading.tsx`, `error.tsx`, `not-found.tsx`, and `route.ts` with the segment they belong to.
- Next.js 15+: `params` and `searchParams` on pages are `Promise`s. Type them as `Promise<{ ... }>` and `await` them. Same for `generateMetadata`.
- `generateStaticParams` for known slugs; call `notFound()` for unknown ones when the set is closed.
- Put server-only I/O (fs, db, secrets) in `page.tsx`, `layout.tsx`, `route.ts`, or `src/lib/` modules that client components never import.
- Navigation uses `next/link`. Do not invent a second client-side router.
- Route handlers (`app/**/route.ts`) return `Response` / `NextResponse`. They are not React components.