Skip to main content
All hooks require being inside a NearProvider. They will throw an error if used outside the provider context.

Read Hooks

These hooks fetch data from the blockchain. They all return a consistent shape:

useView

UseViewParams
required
Call any view method on a NEAR smart contract.
When args change (by reference or value), the hook automatically refetches. Use useMemo for computed args to prevent unnecessary refetches.

useBalance

UseBalanceParams
required
Fetch an account’s NEAR balance as a formatted string.
Returns a human-readable string like "10.50 NEAR". For raw BigInt values, use useNear() and call near.getAccountDetails() directly.

useAccountExists

UseAccountExistsParams
required
Check if a NEAR account exists on the network.

useAccount

Get the current connected account state from the Near client.
Returns:
This hook accesses internal Near client state. The account is derived from whatever signer was configured (wallet adapter, private key, or keystore).

Mutation Hooks

These hooks modify blockchain state. They return a consistent shape:

useCall

UseCallParams
required
Call a change method on a NEAR smart contract.
Cache invalidation not included. After a mutation, related queries won’t automatically refetch. For apps where mutations should update the UI, use React Query with invalidateQueries() instead.

useSend

Send NEAR tokens to another account.
Returns a mutate function with signature:
Where AmountInput is "10 NEAR" | "1000 yocto" | bigint

Utility Hooks

useNear

Access the raw Near client instance for advanced operations:

useContract

string
required
Get a fully-typed contract interface using near.contract<T>().
For reactive data fetching with contracts, combine useContract with useEffect or integrate with React Query. See Data Fetching for patterns.