@near-kit/react provides thin, focused React hooks that wrap the core near-kit library. These hooks handle the React lifecycle for you while giving you full control over caching and data fetching strategies.
Design Philosophy: These hooks are intentionally thin wrappers. They manage loading states and errors, but don’t include built-in caching. For production apps, we recommend pairing them with React Query or SWR.
Installation
@near-kit/react includes near-kit as a dependency — both packages are versioned together.Quick Example
Here’s a complete example showing provider setup, reading data, and sending transactions:Available Hooks
useNear
Access the Near client instance from context
useView
Call view methods on smart contracts
useBalance
Get formatted account balance
useAccountExists
Check if an account exists
useCall
Call contract methods that modify state
useSend
Send NEAR tokens to another account
useAccount
Get full account details and access keys
useContract
Get a typed contract interface
Hook Categories
- Read Hooks
- Mutation Hooks
These hooks fetch data from the blockchain. They return
{ data, error, isLoading, refetch }.What’s Next?
Provider Setup
Configure the NearProvider for your app
Hooks Reference
Complete API reference for all hooks
Data Fetching
Integrate with React Query or SWR
Wallet Connection
Connect user wallets in the browser