Hooks
Last updated
Was this helpful?
Last updated
Was this helpful?
The kit provides hooks for developers to interact with smart contracts like VeBetterDAO, VePassport, veDelegate, and price oracles.
The hooks in this package provide a standardized way to interact with various blockchain and web services. All hooks are built using (formerly React Query), which provides powerful data-fetching and caching capabilities.
Every hook in the @api
directory returns a consistent interface that includes:
data
: The fetched data
isLoading
: Boolean indicating if the request is in progress
isError
: Boolean indicating if the request failed
error
: Error object if the request failed
refetch
: Function to manually trigger a new fetch
isRefetching
: Boolean indicating if a refetch is in progress
Additionally, these hooks integrate with TanStack Query's global features:
Automatic background refetching
Cache invalidation
Optimistic updates
Infinite queries (for pagination)
Parallel queries
Query retrying
Query polling
All hooks use consistent query key patterns, making it easy to invalidate related queries. For example:
By default, most queries are configured with:
staleTime
: How long the data remains "fresh"
cacheTime
: How long inactive data remains in cache
refetchInterval
: For automatic background updates (if applicable)
These can be customized using TanStack Query's global configuration or per-hook options.