Back to Rules
Next.js

Payload CMS Next.js TypeScript Best Practices: Actionable Checklist for Scalable Fullstack Apps

Claude Directory November 29, 2025
0 copies 3 downloads

Elevate your Payload CMS projects with Next.js and TypeScript using this expert checklist. Discover proven patterns for MongoDB optimization, secure APIs, performance boosts, and maintainable code structures.

Rule Content
### Payload CMS Next.js TypeScript Development Checklist

#### Core Technology Stack
- Leverage Payload CMS for backend, MongoDB for data storage, and Node.js/Express for server logic.
- Integrate Next.js or React for frontend, ensuring TypeScript across all layers.
- Connect to external APIs via REST, GraphQL, or webhooks for enhanced data flows.

#### Payload CMS Collection Design
- Organize collections by domain or feature with defined relationships and strict field validation.
- Apply field-level access controls and permissions for secure data handling.
- Reuse field groups and blocks to streamline content modeling.
- Extend via hooks instead of core overrides; add custom endpoints only when essential.
- Manage schema updates through migrations.

#### Recommended File Organization
- Place collections in `src/collections/{feature}.ts`.
- Store globals at `src/globals/{feature}.ts`.
- Define fields in `src/fields/{type}.ts`.
- Group hooks as `src/hooks/{collection}/{operation}.ts`.
- Create endpoints in `src/endpoints/{feature}.ts`.
- Centralize utilities in `src/utilities/{function}.ts`.

#### MongoDB Optimization Strategies
- Add indexes to schemas for high-performance queries.
- Employ aggregation pipelines for advanced data processing.
- Include robust error management and dual-layer validation (app + DB).
- Respect document size limits and use transactions for atomic operations.
- Apply pagination to handle large result sets efficiently.

#### TypeScript Coding Standards
- Mandate TypeScript everywhere; favor types over interfaces for internal use.
- Generate exact types mirroring data models from a shared export hub.
- Eliminate 'any' or excessive 'unknown'; minimize 'as' or '!' assertions.
- Utilize mapped/conditional types for complex transformations.

#### Code Architecture Guidelines
- Craft succinct, functional code avoiding classes; prioritize modularity.
- Employ descriptive names like 'isValid' or 'fetchData'.
- Order files: components first, then queries, helpers, constants, types.
- Replace magic numbers with named constants.

#### Naming and Export Rules
- Default to named exports for reusability.
- Adopt PascalCase for components/types, camelCase for functions/variables.
- Prefix GraphQL hooks with 'use', e.g., `useQueryData.ts`.

#### Syntax and Readability Tips
- Declare pure functions with 'function' keyword.
- Simplify conditionals without braces where possible.
- Destructure props aggressively; prefer async/await over Promises.
- Apply optional chaining (?.) and nullish coalescing (??) liberally.

#### Security Essentials
- Enforce auth/authz, input sanitization, and env-based secrets.
- Add rate limiting and least-privilege API rules.
- Mandate HTTPS and validate all external inputs.

#### Performance Tuning
- Index queries, cache hot data, and paginate/lazy-load lists.
- Optimize assets/images and use SSR/SSG wisely.
- Track and refine API latencies.

#### Testing Framework
- Unit test logic, integrate API tests with mocks.
- E2E test key flows; adopt TDD for core features.

#### Decision-Making Principles
- Query ambiguities, weigh options with trade-offs.
- Align with codebase norms, prioritize scalability/security/maintainability.

Comments

More Rules

View all
AI/ML

GLM-4.7 Optimized Config & System Prompt Designer

Expert system prompt for designing high-performance configurations tailored to GLM-4.7's strengths in coding, reasoning, tool use, and multilingual tasks, backed by benchmarks like SWE-bench and τ²-Bench.

C
Community
AI/ML

GLM-4.7 Open-Source Coding Expert: Optimized System Prompt

Leverage GLM-4.7's top benchmarks in SWE-bench, LiveCodeBench, and more with this system prompt designed for generating clean, secure, open-source-ready code, stunning UIs, and agentic workflows.

C
Community
AI/ML

GLM-4.7 Optimized Coding Agent

This system prompt transforms an AI into GLM-4.7, a benchmark-leading coding agent excelling in agentic workflows, tool use, multilingual coding, and complex reasoning with verified best practices for production-ready open-source development.

C
Community
DevOps

Agentic Dev Loop: Autonomous Jira-Driven Coding Agent with GitHub CI Self-Healing

Ralph, a persistent autonomous AI agent, implements Jira tickets through an endless loop until 100% test success, with GitHub PRs, Jules AI reviews, and CI self-healing for reliable development workflows.

C
Claude Directory
AI/ML

Türk Hukuku Uzmanı AI Agent: Güvenilir Yasal Danışman System Prompt

Claude'u Türk hukuku alanında dünyanın en önde gelen uzmanı olarak yapılandıran, yapılandırılmış yanıtlar, zorunlu uyarılar ve etik sınırlarla donatılmış profesyonel AI agent promptu.

C
Community
Database

PostgreSQL Best Practices: Expert Subagent Guide

Expert subagent providing production-ready PostgreSQL guidance on schema design, query optimization, security, performance tuning, and administration with structured, actionable advice and official references.

C
Claude Directory