hooks
Custom Hook Guidelines
This rule outlines the guidelines for creating custom React hooks within this project.
Custom Hooks
- Purpose: Encapsulate reusable stateful logic, especially for data fetching or complex UI interactions.
- Location: Place custom hooks in the
apps/web/hooks/directory. - Naming: Use the
useprefix (e.g.,useAccounts.ts). - Data Fetching: For fetching data from API endpoints, prefer using
useSWR. Follow the guidelines outlined in data-fetching.mdc.- Create dedicated hooks for specific data types (e.g.,
useAccounts,useLabels). - The hook should typically wrap
useSWR, handle the API endpoint URL, and return the data, loading state, error state, and potentially themutatefunction from SWR.
- Create dedicated hooks for specific data types (e.g.,
- Simplicity: Keep hooks focused on a single responsibility.
By adhering to these guidelines, we ensure a consistent approach to reusable logic and data fetching throughout the application.
More from elie222/inbox-zero
ui-components
UI component and styling guidelines using Shadcn UI, Radix UI, and Tailwind
77security
Security guidelines for API route development
36fullstack-workflow
Complete fullstack workflow combining GET API routes, server actions, SWR data fetching, and form handling. Use when building features that need both data fetching and mutations from API to UI.
23test-feature
End-to-end feature testing — browser QA, API verification, eval tests, or any combination. Covers browser interactions (via agent-browser CLI), Google Workspace operations (gws CLI), API calls, and LLM eval tests. Can also persist tests as reusable QA flows or eval files.
21testing
Guidelines for testing the application with Vitest, including unit tests, integration tests (emulator), AI tests, and eval suites for LLM features
21project-structure
Project structure and file organization guidelines
21