Cursorcursorintermediate
Next.js SaaS .cursorrules Template
A complete .cursorrules file for Next.js SaaS projects with App Router, TypeScript, Tailwind, Supabase, Stripe, and Resend conventions.
What you'll get
A .cursorrules file that enforces consistent conventions across your Next.js SaaS codebase in Cursor.
The Prompt
Create a .cursorrules file in the project root with the following rules for a Next.js SaaS application: PROJECT STACK: - Next.js 14+ with App Router (NO pages/ directory) - TypeScript strict mode — no 'any' types - Tailwind CSS for styling — no CSS modules, no styled-components - Supabase for auth, database, and storage - Stripe for payments - Resend for transactional emails FILE CONVENTIONS: - Components: src/components/[feature]/ComponentName.tsx (PascalCase) - Pages: src/app/[route]/page.tsx - API routes: src/app/api/[route]/route.ts - Server actions: src/app/actions/[name].ts with 'use server' - Types: src/types/[name].ts - Utils: src/lib/[name].ts - Supabase client: src/lib/supabase/client.ts (browser) and server.ts (server) CODING RULES: - Default to Server Components. Only add 'use client' when using hooks, event handlers, or browser APIs. - Use next/image for all images. Never use <img> tags. - Use next/link for all navigation. Never use <a> tags for internal links. - Fetch data in Server Components using Supabase server client. - Handle mutations with Server Actions or API routes, never client-side Supabase writes. - All forms must have loading states, error handling, and success feedback. - Use Zod for validation on both client and server. DO NOT: - Use pages/ directory or getServerSideProps/getStaticProps - Install ORMs (Prisma, Drizzle) — use Supabase client directly - Use CSS-in-JS libraries - Create barrel exports (index.ts re-exports) - Use default exports except for page.tsx and layout.tsx ENVIRONMENT VARIABLES: - NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY - SUPABASE_SERVICE_ROLE_KEY (server only) - STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET - RESEND_API_KEY - NEXT_PUBLIC_SITE_URL
Replace these variables
| Variable | Replace with |
|---|---|
| [PROJECT_NAME] | Name of the SaaS project |
| [STACK_ADDITIONS] | Additional libraries or tools beyond the base stack |
Tips for best results
Place the .cursorrules file in your project root — Cursor reads it automatically.
Review and update the rules as your stack evolves to keep the AI aligned with your conventions.
Follow-up prompts
Add testing rules
Add testing conventions to the .cursorrules: use Vitest for unit tests, Playwright for e2e tests, test file naming (*.test.ts), and testing patterns.
Add Git conventions
Add Git commit message conventions to the .cursorrules: conventional commits format, branch naming (feature/, fix/, chore/), and PR template.