connectWalletOption connects an external wallet by its wallet options catalogue key. It resolves the connection path for that wallet, so you do not need to route by connection option type.
The SDK uses an installed wallet provider when the user has the wallet. Otherwise, it uses a URI pairing through WalletConnect or the MetaMask SDK and passes the URI to onConnectionUri while the promise stays pending until the user approves. If the wallet only provides its own in-app browser, the SDK opens that browser instead.
Usage
- JavaScript
- React
Parameters
Return value
connectWalletOption returns a promise for the connected WalletAccount. The account is not verified. Use verifyWalletAccount or useVerifyWalletAccount to link it to the user.
The promise remains pending for a wallet’s in-app-browser path. The connection completes after the next page load inside the wallet’s browser.
Connection paths
Installed wallet provider
When the user has the wallet installed and the client has a matching wallet provider, the SDK connects through that provider.URI pairing
When an installed provider is not available, the SDK can use WalletConnect or the MetaMask SDK. It callsonConnectionUri with a URI while the connection promise remains pending. The promise resolves after the user approves the connection in the wallet.
The uri is already the wallet’s own deeplink carrying the pairing. The SDK selects the variant the current platform can open for you: the native scheme on mobile, the universal link on desktop, and the other variant as a fallback. For a MetaMask SDK pairing, the URI is MetaMask’s launch link. If a wallet does not publish a deeplink, the URI is the bare pairing URI.
Open the URI on mobile. On desktop, render it as a QR code for the user to scan with the wallet.
Wallet in-app browser
When the wallet has no installed provider or URI pairing, the SDK uses the wallet’s own in-app browser. It callshandleWalletBrowserRedirect with the wallet key and chain. Leave for that browser with redirectToInAppBrowser({ appUrl, chain, walletKey }).
Without the handler, the SDK redirects the current page into the wallet’s browser itself. You only need the handler when you want to choose a different return page or when there is no current page URL, such as in React Native or server-side rendering.
Either way, the returned promise never settles. The connection completes on the next page load inside the wallet’s browser, where the wallet provider is available.
Errors
React
useConnectWalletOption wraps connectWalletOption as a mutation. Pass the connection parameters to connect, not to the hook.
The mutation returns the connected, unverified wallet account in data. Use useVerifyWalletAccount to verify it and link it to the user.