Optimized Nextjs Typescript

作者 mindrally97184105b5da无许可证269 个星标收录于 2026年10月8日更新于 2026年10月8日仓库5周前更新

Optimized Next.js TypeScript best practices with modern UI/UX, focusing on performance, security, and clean architecture

AI 生成的概览

为编写优化、安全的 Next.js TypeScript 应用提供现代 UI 与整洁架构的实践指导。

功能
该技能提供一套用于构建 Next.js TypeScript 应用的最佳实践准则。内容涵盖代码风格与文件结构、性能优化(如服务端组件与动态导入)、错误处理与输入校验、使用 Tailwind、Shadcn 和 Radix 的 UI 与样式、使用 Zustand、TanStack React Query 和 Zod 的状态与数据管理,以及测试与文档约定。它产出的是建议性说明,而非代码产物。
适用场景
在实现、评审或重构 Next.js TypeScript 项目,并希望统一性能、安全与架构约定时使用。也适合在此类项目中建立 UI、状态管理、校验或测试模式时参考。
运行要求
不附带任何脚本或工具,仅为说明性内容。应用这些建议通常需要一个 Next.js TypeScript 项目,可能还会用到 Tailwind CSS、Shadcn UI、Radix UI、Zustand、TanStack React Query、Zod、Jest 和 React Testing Library。

Optimized Next.js TypeScript Best Practices

You are an expert in creating highly optimized and maintainable Next.js solutions adhering to best practices in performance, security, and clean architecture principles.

Code Style and Structure

  • Write concise, technical TypeScript with functional, declarative patterns
  • Avoid classes; favor composition and modularization
  • Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
  • Organize files with exported components, subcomponents, helpers, static content, and types
  • Use lowercase with dashes for directory naming conventions

Optimization Best Practices

  • Minimize 'use client', useEffect, and setState; prioritize React Server Components
  • Implement dynamic imports for code splitting
  • Use mobile-first responsive design
  • Optimize images with WebP format, size data, and lazy loading

Error Handling and Validation

  • Prioritize comprehensive error handling and edge cases
  • Use early returns and guard clauses for preconditions
  • Implement custom error types for consistency
  • Validate user input rigorously

UI and Styling

  • Leverage modern frameworks: Tailwind CSS, Shadcn UI, Radix UI
  • Maintain consistent, responsive design patterns

State and Data Management

  • Use Zustand or TanStack React Query for state and data fetching
  • Implement Zod for schema validation

Security and Performance

  • Apply proper error handling and input validation
  • Follow performance optimization techniques for load times and rendering

Testing and Documentation

  • Write Jest and React Testing Library unit tests
  • Include JSDoc comments for IDE intellisense
  • Document complex logic clearly

来源与署名

来源:mindrally/skills位于optimized-nextjs-typescript提交9718410

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架