Skip to main content

API Patterns

Fetching Data

  • Server components: Fetch directly using the database client or tRPC server caller
  • Client components: Use tRPC React Query hooks via the api export from @/lib/api/client

Mutations

  • Use server actions (in _actions.ts files) for all mutations
  • Server actions handle validation, auth checks, and database operations
  • Always revalidate relevant paths after mutations

Roles

RoleDescription
USERDefault role — can leave reviews
ADMINAccess to admin dashboard
SUPERADMINFull access including user management

Role guards are available in src/components/auth/ for both client and server-side protection.