connect
Initiates a wallet connection by prompting the user to select a wallet and then requesting their addresses. This is a convenience wrapper around request that calls getAddresses with forceWalletSelect: true.
Usage
import { connect } from '@stacks/connect';
const response = await connect();
console.log('Addresses:', response.addresses);import { connect } from '@stacks/connect';
// With options
const response = await connect({
forceWalletSelect: true,
approvedProviderIds: ['LeatherProvider', 'XverseProviders.BitcoinProvider'],
network: 'mainnet',
});Notes
This always opens the wallet selection modal, regardless of whether a wallet was previously selected.
The returned addresses include both STX and BTC addresses provided by the wallet.
Accepts all
ConnectRequestOptionsproperties as well asGetAddressesParams(e.g.network).
Signature
Returns
Promise<GetAddressesResult>
An object containing an addresses array. Each entry includes the address string, its public key, and an optional symbol (e.g. 'STX' or 'BTC').
Parameters
options (optional)
Type:
ConnectRequestOptions & MethodParams<'getAddresses'>
Combines all properties from ConnectRequestOptions with GetAddressesParams.
The additional parameter from GetAddressesParams:
network
NetworkString
No
The network to request addresses for (e.g. 'mainnet', 'testnet').
Last updated
Was this helpful?