Connect Wallet
This example shows how to build a basic "connect wallet" interface with Starknet React.
You will learn the basic concepts, such as:
- what are connectors, provider, and chains.
- how to connect and disconnect the user's wallet.
- how to display the currently connected account.
Your Wallet
Connect wallet to get started
Configure StarknetConfig
The first step is to configure the root Starknet context. Refer to the "Getting Started" guide to learn how to set it up.
Root connect wallet component
We are going to add a root wallet component that, based on the current wallet connection status, will display either the "connect wallet" or the "disconnect wallet" interface.
Important
You need to disable Server Side Rendering (SSR) for the wallet-related
components to handle browser (injected) wallets.
This example uses Next.js and so we use dynamic
with ssr: false
.
Connect wallet modal
The next component is a "connect wallet modal". We use the useConnect
hook to
list all availale connectors from StarknetConfig
and to allow the user to
connect to one.
Disconnect wallet modal
This component shows the currently-connected address and a modal to disconnect the wallet from the dapp.
Where to go from here
This guide showed how to build a simple connect wallet ui.