Data Fetching Hooks
Hooks for fetching data from the Solana blockchain
These hooks provide easy access to common Solana blockchain data with automatic caching, refetching, and error handling.
useAccount
Get the account info for an address using the Solana RPC method
getAccountInfo
.
Usage
With Decoder
Fetch and decode an account's data into a typed object using an appropriate decoder
function:
Parameters
useBalance
Get an account's balance in lamports using
getBalance
.
Usage
With Automatic Refetch
Parameters
useLatestBlockhash
Get the latest blockhash using
getLatestBlockhash
.
Usage
For Transactions
Parameters
useSignatureStatuses
Get the statuses of signatures using
getSignatureStatuses
.
Usage
Multiple Signatures
Parameters
useSignaturesForAddress
Get signatures for confirmed transactions using
getSignaturesForAddress
.
Usage
With Pagination
Parameters
useProgramAccounts
Get all accounts owned by a program using the
getProgramAccounts
RPC method.
Important getProgramAccounts (GPA) Limitations
getProgramAccounts
can return large amounts of data and is resource-intensive- Many RPC providers return errors or have rate limits due to the system load
- Public RPC endpoints often have
getProgramAccounts
disabled entirely - Consider using filters to reduce the data returned and always use a paid RPC provider for production
- For large programs, consider alternative approaches like indexers or specialized APIs
Usage
With Memcmp Filter
Parameters
useTokenMint
Get a decoded Mint account for a token.
Usage
Parameters
useTokenAccount
Get the decoded Token Account for a given mint and owner, automatically deriving the Associated Token Account (ATA) address:
Usage
With ATA Address
If you need to fetch and decode a specific Token Account's address (like for ancillary token accounts), you can manually derive the address and provide it to the hook: