A React SDK for Web3Auth integration with Starknet blockchain. This package provides React hooks and utilities for seamless Web3Auth integration in React applications.
npm install w3a-react
# or
yarn add w3a-react
# or
pnpm add w3a-reactimport React from "react";
import { useWeb3AuthStatus, useConnect, useAccount } from "w3a-react";
function App() {
const { isConnected, isLoading } = useWeb3AuthStatus();
const { connect, disconnect } = useConnect();
const { account } = useAccount();
if (isLoading) {
return <div>Loading...</div>;
}
return (
<div>
{!isConnected ? (
<button onClick={connect}>Connect Wallet</button>
) : (
<div>
<p>Connected: {account?.address}</p>
<button onClick={disconnect}>Disconnect</button>
</div>
)}
</div>
);
}useWeb3AuthStatus()- Get connection statususeConnect()- Connect/disconnect functionalityuseAccount()- Get current account informationuseBalance()- Get account balanceuseNetwork()- Get network informationuseProvider()- Get Starknet provideruseContract()- Interact with smart contractsuseCall()- Make read calls to contractsuseSendTransaction()- Send transactionsuseBlockNumber()- Get current block numberuseInvalidateOnBlock()- Invalidate queries on new blocks
The SDK supports both mainnet and testnet (sepolia) configurations:
import { mainnet, sepolia } from "w3a-react";
// Use mainnet
const mainnetConfig = mainnet;
// Use testnet
const testnetConfig = sepolia;- Install dependencies:
pnpm install- Build the SDK:
pnpm run build- Start development server:
pnpm devMIT