Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save marcelloinfoweb/89fd6e73d17292467197e86e7be17697 to your computer and use it in GitHub Desktop.

Select an option

Save marcelloinfoweb/89fd6e73d17292467197e86e7be17697 to your computer and use it in GitHub Desktop.

Next.js 16 + React 19 – Cursor Project Rules

  • Use Next.js 16 App Router only; never use pages/.

  • Default to React Server Components; add 'use client' only when interactivity or browser APIs are required.

  • Keep routes under app/ (or src/app/): use page.tsx, layout.tsx, loading.tsx, error.tsx, not-found.tsx where appropriate.

  • Use route groups and nested layouts to organize sections (e.g. app/(marketing)/, app/(app)/dashboard/).

  • Organize code as:

    • app/ – routes, layouts, API routes.
    • components/ – shared UI components.
    • lib/ – utilities, services, API/db clients, validation.
    • hooks/ – React hooks (client-only).
    • types/ – shared TypeScript types.
    • public/ – static assets.
  • Use TypeScript everywhere (.ts / .tsx); no .js / .jsx.

  • Define explicit types/interfaces for props and exported functions; avoid any.

  • Prefer interfaces for object shapes and props.

  • Use named exports for components and utilities; avoid default exports except for app/**/page.tsx.

  • Use PascalCase for React components and their files (e.g. UserCard.tsx).

  • Use camelCase for variables, functions, and hooks (useSomething).

  • Use absolute imports with @/ (configured in tsconfig.json); do not use deep relative imports like ../../components/....

  • Centralize HTTP/API requests in lib/api.ts (or equivalent) and import from there; do not scatter raw fetch calls across components.

  • Style UI using Tailwind CSS utility classes; do not introduce new CSS frameworks.

  • Keep globals.css minimal and reserved for truly global styles (fonts, resets, layout primitives).

  • In Server Components, perform data fetching with async/await and Next.js 16 conventions (async route params, searchParams).

  • In Client Components, keep useState, useEffect, and other hooks minimal and focused on UI behavior.

  • Use Suspense and streaming where beneficial; keep heavy logic on the server.

  • Define API routes only in app/api/**/route.ts.

  • Export HTTP verbs (GET, POST, etc.) as async functions using NextResponse.

  • Validate request bodies and query params with a schema library (e.g. Zod) before using them.

  • Always return structured JSON and appropriate HTTP status codes.

  • Match existing patterns in this repo for folder structure, naming, imports, error handling, and Tailwind class style.

  • Do not add new dependencies, tools, or architectural patterns without an explicit instruction in the prompt.

  • Respect existing ESLint/Prettier configuration; do not generate code that violates formatting or lint rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment