abhishek-kumar-13/nextjs-rules-enterprise icon
public
Published on 8/6/2025
Next Enterprise

Rules
  • Auto-detect or ask for the versions of Next.js, Tailwind CSS, and other packages used in the project to align generated code
    • Use Next.js App Router structure (app/, layout.tsx, page.tsx, server actions, metadata)
    • Generate modular, production-ready TypeScript code with async/await, error handling, loading states
    • Uses environment-based configs and .env scoping best practices.
    • Use TypeScript best practices — interfaces, utility types, and explicit return types
    • Use Tailwind CSS v4 with utility-first styling, dark/light mode support, responsive and mobile-first design
    • Apply modern UI/UX patterns using semantic UI, responsive layout, ARIA accessibility, proper spacing, and visual hierarchy
    • Create MongoDB/Mongoose models with schema validation, indexes, and reusability
    • Setup and handle GraphQL schemas, resolvers, and client-side queries/mutations using Apollo/Yoga
    • Always use Hybrid api approach, REST for CRUD and GraphQl for Fetching.
    • Suggest best folder structures (app/, components/, lib/, models/, graphql/, styles/)
    • Include performance optimizations: lazy loading, next/image, metadata, layout shift prevention
    • Generate SEO-friendly markup using metadata, OpenGraph, and structured data if applicable
    • Proactively identify common bugs (e.g., hydration issues, Tailwind class conflicts, state desync) and avoid them in output
    • Propose refactors for slow/anti-pattern code (e.g., deep prop drilling, large server components)
    • Avoid unnecessary complexity; prioritize developer readability and scalability
    • Handle multilingual design (i18n, RTL support) when project requires
    • Provide testable mock data, and sample query response formats
    • Avoid overly generic output; tailor code to the actual problem with minimal boilerplate
    • Suggest improvements in performance, structure, accessibility, or UX when relevant
    • Avoid verbose explanations unless explicitly requested
    • Always follow enterprise grade product security
    • JWT-based auth (access + refresh tokens)
    • OAuth 2.0 integrations (Google, GitHub, etc.)
    • Secure cookie setup (httpOnly, SameSite, Secure)
    • RBAC (Role-Based Access Control) logic
    • Guards API routes with middleware