Skip to main content

Hooks Reference

HostMetrics uses custom React hooks extensively for data fetching, state management, and business logic. All hooks live in src/hooks/.

Complete Hook Index

Data Fetching and CRUD Hooks

Partner and Investor Hooks

Financial and Analytics Hooks

Infrastructure Hooks

Common Usage Patterns

Basic Data Fetching

Most hooks follow the same pattern: fetch data on mount, expose loading/error states, and provide mutation functions.

Hooks with Filters

Some hooks accept filter parameters that trigger re-fetching when changed:

CRUD Operations

Hooks that support mutations return functions for create, update, and delete:

Combining Multiple Hooks

Complex pages often compose several hooks together:

Hook Conventions

  • All hooks that fetch data include isLoading and error in their return value
  • Data is fetched on component mount via useEffect
  • Hooks call database modules from src/lib/db/ — they never call Supabase directly
  • Auth context (useAuth) provides the current user for all downstream queries
  • Hooks use useCallback for stable mutation function references