Hooks
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 TanStack Query (formerly React Query), which provides powerful data-fetching and caching capabilities.
Common Features
Every hook in the @api
directory returns a consistent interface that includes:
data
: The fetched dataisLoading
: Boolean indicating if the request is in progressisError
: Boolean indicating if the request failederror
: Error object if the request failedrefetch
: Function to manually trigger a new fetchisRefetching
: 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
Query Invalidation
All hooks use consistent query key patterns, making it easy to invalidate related queries. For example:
Caching Behavior
By default, most queries are configured with:
staleTime
: How long the data remains "fresh"cacheTime
: How long inactive data remains in cacherefetchInterval
: For automatic background updates (if applicable)
These can be customized using TanStack Query's global configuration or per-hook options.
Last updated
Was this helpful?