All examples

Next.js app (TypeScript), Cursor rule

The Next.js rules as a Cursor .mdc rule: same content, with frontmatter that applies it to every request.

Composed from the nextjs-typescript rules pack. Same file from the CLI: aibysitter init --packs nextjs-typescript --format cursor

Written for this site, CC0, scored by this linter, not tested against any agent.

File
nextjs.mdc, 43 lines
Format
Cursor rule (.mdc)
Save as
.cursor/rules/nextjs.mdc
Category
JavaScript
Tags
License
CC0 1.0, public domain. No attribution needed.

Download nextjs.mdc Lint a copy

Aibysitter lint score

100 / 100 — A

Ruleset v4

No deductions.

Badge

Aibysitter lint score: A 100

Markdown for a README:

[![Aibysitter lint score: A 100](https://aibysitting.net/gallery/nextjs-typescript-cursor/badge.svg)](https://aibysitting.net/Gallery/nextjs-typescript-cursor)

nextjs.mdc

View rendered

  1. ---
  2. description: Next.js with TypeScript
  3. alwaysApply: true
  4. ---
  5. # Next.js with TypeScript
  6. Next.js with the App Router, TypeScript in strict mode, Tailwind CSS. Package manager: pnpm.
  7. ## Commands
  8. - Install: `pnpm install --frozen-lockfile`
  9. - Dev server: `pnpm dev`
  10. - Type check: `pnpm tsc --noEmit`
  11. - Lint: `pnpm lint`
  12. - Unit tests: `pnpm test` (Vitest)
  13. - End-to-end tests: `pnpm test:e2e` (Playwright)
  14. ## Structure
  15. - Routes live in `app/`. Shared UI lives in `components/`. Data access lives in `lib/data/`.
  16. - Components are Server Components by default. A component that uses state, effects, or browser APIs starts with `"use client"`.
  17. - Client components receive data as props. Data fetching stays in the Server Component that renders them.
  18. - Mutations are Server Actions in `app/**/actions.ts` and call `revalidatePath` for the route they change.
  19. ## TypeScript
  20. - No `any`. Use `unknown` and narrow it.
  21. - No non-null assertions (`!`) outside tests.
  22. - Form data, route params, and API responses are parsed with the Zod schemas in `lib/schemas/` before use.
  23. ## Styling
  24. - Tailwind classes only. No inline `style` attributes and no new CSS files.
  25. - Colors come from the theme tokens in `app/globals.css`. No raw hex values in components.
  26. ## Server code
  27. - Modules that read secrets or the database import `server-only` on their first line.
  28. - Secrets are read from `process.env` in server code only. Secret names never start with `NEXT_PUBLIC_`.
  29. ## Tests
  30. - A component with logic gets a Vitest test next to it: `ProductCard.test.tsx` for `ProductCard.tsx`.
  31. - A new route gets one Playwright test in `e2e/` covering its main path.
  32. ## Before opening a PR
  33. - `pnpm tsc --noEmit`, `pnpm lint`, and `pnpm test` pass.
  34. - No `console.log` calls remain in `app/`, `components/`, or `lib/`.