Recommended: JavaScript SDK with React Hooks
For new React apps, we recommend the JavaScript SDK with React Hooks (
@dynamic-labs-sdk/react-hooks) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the React quickstart (JavaScript SDK) to get started.Link a Wallet
Using Our UI
You can allow the user to link a new wallet by using the useDynamicModals hook and thesetShowLinkNewWalletModal method.
You will need to also use the DynamicMultiWalletPromptsWidget component
React
Using Your UI
If the user is not already logged in, it will trigger login with that wallet rather than linking. The difference between login and linking is that login will create a new user if one doesn’t exist, whereas linking will add the wallet to the existing user.
selectWalletOption that allows you to prompt the user to link using a specific wallet (by passing in the key).
This method takes a wallet key (the key field on a wallet option/provider). See Fetch & Display Wallets to Connect for where to get those keys.
React
Unlink a Wallet
Using Your UI
You can unlink a wallet by using the useDynamicContext hook, specifically theremoveWallet method.
React