

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# Next.js 14+ with TypeScript — Cursor Rules23You are an expert Next.js 14+ developer using TypeScript, the App Router, React Server Components, and Server Actions.45## Code Style67- Use TypeScript strict mode for all files. Never use `any` — prefer `unknown` with type narrowing.8- Use named exports for components and functions. Default exports only for page.tsx, layout.tsx, loading.tsx, error.tsx, and not-found.tsx.9- Prefer `const` arrow functions for components: `const MyComponent = () => { ... }`.10- Use descriptive variable names: `isLoading`, `hasPermission`, `userList` — not `flag`, `data`, `arr`.11- Import order: React/Next built-ins, third-party libraries, project aliases (@/), relative imports. Separate groups with blank lines.12- Use `type` keyword for type-only imports: `import type { User } from '@/types'`.13- Prefer `interface` for object shapes that may be extended. Use `type` for unions, intersections, and mapped types.14- File naming: kebab-case for files and folders (`user-profile.tsx`). PascalCase for components in code.1516## App Router Architecture1718- Default to Server Components. Only add `'use client'` when the component needs interactivity (event handlers, useState, useEffect, browser APIs).19- Keep `'use client'` boundaries as low in the component tree as possible. Extract interactive parts into small client components.20- Use `page.tsx` for route pages, `layout.tsx` for shared layouts, `loading.tsx` for Suspense fallbacks, `error.tsx` for error boundaries.21- Colocate related files: put components, utils, and types used by a single route inside that route's folder.22- Use route groups `(group-name)` to organize routes without affecting the URL structure.23- Use `generateMetadata` or `metadata` export for SEO on every page. Never skip metadata.2425## Data Fetching2627- Fetch data in Server Components using `async/await` directly — no useEffect for initial data loads.28- Use `fetch()` with Next.js extended options for caching: `{ cache: 'force-cache' }` for static, `{ next: { revalidate: 3600 } }` for ISR, `{ cache: 'no-store' }` for dynamic.29- Use Server Actions (`'use server'`) for mutations (form submissions, data updates). Define them in separate `actions.ts` files.30- Validate all Server Action inputs with Zod schemas before processing.31- Use `revalidatePath()` or `revalidateTag()` after mutations to update cached data.32- Prefer parallel data fetching: `const [users, posts] = await Promise.all([getUsers(), getPosts()])`.3334## React Server Components3536- Never import or use hooks (useState, useEffect, etc.) in Server Components.37- Never pass functions or event handlers as props from Server Components to Client Components.38- Serialize data at the Server Component level — pass only plain objects and primitives to Client Components.39- Use the `Suspense` boundary with `loading.tsx` or inline `<Suspense fallback={...}>` for streaming.40- Prefer React Server Components for any component that doesn't need client-side interactivity.4142## Error Handling4344- Use `error.tsx` boundaries at route segment levels. Always provide a user-friendly message and a retry mechanism.45- Wrap Server Action logic in try/catch blocks. Return structured results: `{ success: boolean, data?: T, error?: string }`.46- Use `notFound()` from `next/navigation` to trigger 404 pages when a resource doesn't exist.47- Log errors server-side with structured logging (include request context). Never expose stack traces to the client.4849## Performance5051- Use `next/image` for all images. Always provide `width`, `height`, and `alt` props. Use `priority` for above-the-fold images.52- Use `next/font` for font loading — prefer `next/font/google` with `display: 'swap'`.53- Use dynamic imports with `next/dynamic` for heavy client components that aren't needed on initial render.54- Prefer CSS Modules or Tailwind CSS. Avoid runtime CSS-in-JS libraries in Server Components.55- Use `generateStaticParams` for static generation of dynamic routes when the data set is known.56- Minimize client-side JavaScript: fewer `'use client'` files = faster page loads.5758## Testing5960- Use Vitest for unit tests and React Testing Library for component tests.61- Use Playwright for end-to-end tests. Place e2e tests in a top-level `e2e/` directory.62- Test Server Actions by calling them directly with mock inputs.63- Colocate unit tests with the code they test: `user-profile.test.tsx` next to `user-profile.tsx`.64- Name test files with `.test.ts` or `.test.tsx` suffix.6566## File Structure6768```69app/70 (auth)/71 login/page.tsx72 register/page.tsx73 (dashboard)/74 layout.tsx75 page.tsx76 settings/page.tsx77 api/78 route.ts79 layout.tsx80 page.tsx81 globals.css82components/83 ui/ — Reusable UI primitives (Button, Card, Modal)84 features/ — Feature-specific components85lib/86 actions/ — Server Actions87 db/ — Database client and queries88 utils/ — Utility functions89 validations/ — Zod schemas90types/91 index.ts — Shared TypeScript types92```9394## Security9596- Validate and sanitize all user inputs on the server (Server Actions, API routes).97- Use `headers()` and `cookies()` from `next/headers` for auth checks in Server Components.98- Never expose API keys or secrets in client components. Use server-only modules and environment variables.99- Mark sensitive server-only modules with `import 'server-only'` to prevent accidental client imports.100- Use CSRF protection for Server Actions (Next.js handles this by default with the same-origin check).101- Set appropriate CSP headers via `next.config.js` `headers()` configuration.102
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| survivorforge/cursor-rulesrules/ai-ml-python/.cursorrules · 17 | .cursorrules | teststylearchdeployment+2 | 81/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/api-microservices/.cursorrules · 17 | .cursorrules | buildteststylearch+5 | 92/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/database-sql/.cursorrules · 17 | .cursorrules | styletypessecuritydatabase+3 | 65/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/devops-docker/.cursorrules · 17 | .cursorrules | setupbuildteststyle+4 | 93/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/devops-infrastructure/.cursorrules · 17 | .cursorrules | buildteststylesecurity+3 | 93/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/django-rest/.cursorrules · 17 | .cursorrules | buildteststylearch+5 | 84/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/docker-devops/.cursorrules · 17 | .cursorrules | setupteststylearch+6 | 85/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/flutter-dart/.cursorrules · 17 | .cursorrules | teststylearchtypes+5 | 89/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/go-gin/.cursorrules · 17 | .cursorrules | testlint-formatstylearch+5 | 84/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/langchain-ai/.cursorrules · 17 | .cursorrules | testlint-formatstylearch+4 | 84/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/mobile-react-native/.cursorrules · 17 | .cursorrules | teststylearchtypes+7 | 89/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/nextjs-14-app-router/.cursorrules · 17 | .cursorrules | teststyletypestesting-strategy+3 | 71/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/nextjs-app-router/.cursorrules · 17 | .cursorrules | teststylearchtypes+5 | 81/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/nextjs/.cursorrules · 17 | .cursorrules | teststylearchtypes+5 | 81/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/nodejs-express-typescript/.cursorrules · 17 | .cursorrules | setupteststylearch+7 | 81/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/nodejs-express/.cursorrules · 17 | .cursorrules | testlint-formatstylearch+7 | 92/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/performance-optimization/.cursorrules · 17 | .cursorrules | styledatabaseapiperformance+2 | 65/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/python-django/.cursorrules · 17 | .cursorrules | testlint-formatstylearch+6 | 99/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/python-fastapi/.cursorrules · 17 | .cursorrules | testlint-formatstylearch+6 | 99/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/python-modern/.cursorrules · 17 | .cursorrules | testlint-formatstyletypes+3 | 88/100 | 13 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/survivorforge-cursor-rules-rules-nextjs-typescript-cursorrules)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.