React Hooks Reference
Complete reference for all available hooks in @gillsdk/react
@gillsdk/react
provides a comprehensive set of React hooks for interacting with the Solana
blockchain. All hooks are built on top of TanStack Query, providing automatic caching, background
refetching, and error handling.
Hook Categories
Client Management
Hooks for managing and accessing the Solana client connection:
useSolanaClient
- Get the current Solana clientuseUpdateSolanaClient
- Update the Solana client
Data Fetching
Hooks for fetching data from the Solana blockchain:
useAccount
- Get account info and datauseBalance
- Get an account's balanceuseLatestBlockhash
- Get the latest blockhashuseSignatureStatuses
- Get the statuses of signaturesuseSignaturesForAddress
- Get signatures for an addressuseProgramAccounts
- Get all accounts owned by a programuseTokenMint
- Get a token mint accountuseTokenAccount
- Get a token account
Transaction Handling
Hooks for sending and managing transactions (coming soon):
useSendTransaction
- Send transactions with automatic confirmationuseSimulateTransaction
- Simulate transactions before sending
Common Hook Options
All data fetching hooks in @gillsdk/react
accept standard TanStack Query options:
Common Return Values
All data fetching hooks return a consistent shape based on TanStack Query:
Error Handling
All hooks provide built-in error handling. You can handle errors at the component level:
Or configure global error handling through TanStack Query:
Performance Tips
- Use
staleTime
wisely - Set appropriate stale times to reduce unnecessary refetches - Enable queries conditionally - Use the
enabled
option to prevent unnecessary queries - Batch requests - Multiple hooks can share the same query key to deduplicate requests
- Implement pagination - For large datasets, use pagination parameters
TypeScript Support
All hooks are fully typed with TypeScript. Import types from gill
for complete type safety: