Skip to main content

@kea-wallet/react-sdk

React SDK for KEA Wallet — provider, hooks, and context for integrating KEA Wallet into React applications.

Installation

npm install @kea-wallet/react-sdk

Quick Start

import { KeaProvider, useWallet } from '@kea-wallet/react-sdk';

const config = { rpcUrl: 'https://grpc-web.alphanet.thruput.org' };

function App() {
return (
<KeaProvider config={config}>
<WalletButton />
</KeaProvider>
);
}

function WalletButton() {
const { connect, isConnected, selectedAccount } = useWallet();
return <button onClick={() => connect()}>
{isConnected ? selectedAccount?.address : 'Connect'}
</button>;
}

Key Concepts

  • Provider-first — wrap your app (or subtree) with KeaProvider to initialize the SDK and enable the wallet hooks.
  • Hook hierarchyuseWallet (primary, connection + accounts) → useAccounts (account state only) → useKea (raw context).
  • Event-driven state — React state updates automatically via SDK events (connect, disconnect, accountChanged, lock, error).
  • gRPC-web RPC — blockchain queries via ThruClient, configured by rpcUrl in BrowserSDKConfig.

See

Lifecycle

FunctionDescription
KeaProviderReact context provider that initializes the KEA Wallet SDK and manages wallet state (connection, accounts, errors). Wrap your app (or the relevant subtree) with this component to enable the wallet hooks.

Connection

FunctionDescription
useWalletPrimary hook for wallet operations — connect, disconnect, sign, and track account state.

Accounts

FunctionDescription
useAccountsAccount-focused hook that provides account state and an optional callback when the selected account changes.

Other

BrowserSDK

Renames and re-exports BrowserSDKConfig


ConnectOptions

Renames and re-exports BrowserSDKConfig


ConnectResult

Renames and re-exports BrowserSDKConfig


ErrorCode

Renames and re-exports BrowserSDKConfig


IThruChain

Renames and re-exports BrowserSDKConfig


SDKEvent

Renames and re-exports BrowserSDKConfig


WalletAccount

Renames and re-exports BrowserSDKConfig