Skip to main content

React Hooks

The SDK provides React hooks built on TanStack Query for seamless data fetching with caching, background updates, and error handling.

Setup

Wrap your app with QueryClientProvider:

DAO Hooks

useDAOs

Fetch all DAOs with pagination and ordering.
ParameterTypeDescription
limitnumberMax items to return
afterstringCursor for forward pagination
beforestringCursor for backward pagination
orderBy'createdAt' | 'proposalCount' | 'name'Sort field
orderDirection'asc' | 'desc'Sort direction

useDAO

Fetch a single DAO by ID.
See Types Reference for full DAO type.

useDAOsByManager

Fetch DAOs managed by a specific address.

Proposal Hooks

useProposals

Fetch proposals with optional filters.
ParameterTypeDescription
limitnumberMax items to return
daoIdstringFilter by DAO ID
stateProposalStateFilter by proposal state
proposerstringFilter by proposer address
orderBy'createdAt' | 'voteEnd' | 'voteStart'Sort field
orderDirection'asc' | 'desc'Sort direction

useProposal

Fetch a single proposal by ID.

useProposalsByDAO

Fetch proposals for a specific DAO.

useActiveProposals

Fetch all currently active proposals across all DAOs.

Vote Hooks

useVotes

Fetch votes with optional filters.
ParameterTypeDescription
proposalIdstringFilter by proposal ID
daoIdstringFilter by DAO ID
voterstringFilter by voter address
support'FOR' | 'AGAINST' | 'ABSTAIN'Filter by vote type
orderBy'createdAt' | 'weight'Sort field

useVotesByProposal

Fetch all votes for a specific proposal.

useVotesByVoter

Fetch all votes cast by a specific address.

Delegate Hooks

useDelegates

Fetch delegation records with optional filters.

useDelegatesByDAO

Fetch delegates for a specific DAO.

useDelegationsFrom / useDelegationsTo

Fetch delegations from or to a specific address.

Token Holder Hooks

useTokenHolders

Fetch token holders with optional filters.

useTokenHoldersByDAO

Fetch token holders for a specific DAO.

useTokenHoldingsByAddress

Fetch all token holdings for a specific address across all DAOs.

Query Keys

Each hook exports query keys for cache invalidation with TanStack Query:

Available Query Keys

ExportKeys
daoKeys.all, .lists(), .list(params), .byManager(params), .details(), .detail(id)
proposalKeys.all, .lists(), .list(params), .byDAO(daoId), .active(params), .details(), .detail(id)
voteKeys.all, .lists(), .list(params), .byProposal(id), .byVoter(voter), .details(), .detail(id)
delegateKeys.all, .lists(), .byDAO(daoId), .delegationsFrom(addr), .delegationsTo(addr), .details(), .detail(id)
tokenHolderKeys.all, .lists(), .byDAO(daoId), .byAddress(addr), .details(), .detail(id)