Next.js + Tailwind Development Guidelines
Tech Stack: Next.js 15, React 19, Tailwind CSS v4, Radix UI, TanStack Query, ThirdWeb SDK v5, TypeScript 5
This skill provides development guidelines specifically for the Zap Pilot frontend codebase. It follows a progressive disclosure pattern - start here for the overview, then consult specific resource files as needed.
Core Principles
- Service-First Architecture: All API operations use service functions (no classes)
- Component Composition: Reusable, well-typed components with clear interfaces
- Type Safety: Comprehensive TypeScript with strict configuration
- Performance: Lazy loading, memoization, and React Query caching
- Accessibility: ARIA labels and keyboard navigation support
Quick Reference
When Working With...
- Components: See
@components.mdfor Radix UI patterns, composition, and prop interfaces - Routing: See
@routing.mdfor Next.js App Router patterns, navigation, and dynamic routes - Data Fetching: See
@data-fetching.mdfor TanStack Query patterns and caching strategies - Styling: See
@styling.mdfor Tailwind utilities, design tokens, and animations - Web3: See
@web3-integration.mdfor ThirdWeb SDK, wallet connectivity, and chain management
Project Structure
frontend/
├── src/
│ ├── app/ # Next.js App Router pages
│ │ ├── layout.tsx # Root layout with providers
│ │ ├── page.tsx # Home page
│ │ └── bundle/ # Bundle sharing feature
│ ├── components/ # Feature-based component organization
│ │ ├── ui/ # Design system components
│ │ ├── PortfolioAllocation/ # Portfolio management
│ │ ├── SwapPage/ # Trading interface
│ │ ├── Web3/ # Wallet connectivity
│ │ └── shared/ # Cross-feature components
│ ├── hooks/ # Custom hooks for business logic
│ │ ├── queries/ # React Query hooks
│ │ └── *.ts # Domain-specific hooks
│ ├── services/ # API integration (service functions)
│ │ ├── accountService.ts # User & wallet management
│ │ ├── intentService.ts # Transaction execution
│ │ └── analyticsService.ts # Portfolio analytics
│ ├── providers/ # React Context providers
│ ├── lib/ # Utilities and helpers
│ ├── types/ # TypeScript definitions
│ └── config/ # Configuration files
├── tests/ # Vitest unit tests and Playwright E2E
├── public/ # Static assets and PWA configuration
├── package.json
└── next.config.ts
Common Development Tasks
Creating a New Component
- Define types in component file or
src/types/ - Create service functions in appropriate
src/services/file - Create custom hooks for business logic in
src/hooks/ - Build UI component with proper TypeScript types
- Add tests in
tests/unit/ - Document with JSDoc comments
Creating a New API Integration
- Add service function in
src/services/[feature]Service.ts - Create React Query hook in
src/hooks/queries/ - Handle loading, error, and success states
- Add error boundaries where needed
Adding a New Page
- Create route in
src/app/[route]/page.tsx - Set up layout if needed (
layout.tsx) - Implement page component with proper meta tags
- Add navigation links
- Test routing and data fetching
Development Workflow
# Type check
npm run type-check
# Run tests
npm run test:unit
# Lint and format
npm run lint
npm run format
# Start dev server
npm run dev
File Naming Conventions
- Components: PascalCase (e.g.,
PortfolioCard.tsx) - Hooks: camelCase with
useprefix (e.g.,usePortfolioData.ts) - Services: camelCase with
Servicesuffix (e.g.,analyticsService.ts) - Utils: camelCase (e.g.,
formatCurrency.ts) - Types: PascalCase (e.g.,
PortfolioData.ts) - Test files:
*.test.tsor*.spec.ts
Progressive Disclosure Resources
For detailed guidance on specific topics, reference these files:
@components.md- Radix UI patterns, component composition, prop interfaces, design system@routing.md- Next.js App Router, dynamic routes, navigation, layouts@data-fetching.md- TanStack Query patterns, caching, mutations, optimistic updates@styling.md- Tailwind CSS utilities, design tokens, animations, responsive design@web3-integration.md- ThirdWeb SDK integration, wallet connectivity, transaction handling@main.md- Additional patterns, error handling, testing standards, security practices
Use @filename.md syntax to include specific resource files when needed for deeper guidance.
Scan to join WeChat group