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 從公開儲存庫中收錄這些內容。

檢舉或申請下架