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.Fetching Enabled Networks
The wallet connector provides thegetEnabledNetworks method:
React
Example
React
Network Switching
Usage
Using the primaryWallet provided by useDynamicContext, you have two useful methods for network switching:() => boolean
Available on the connector object for the wallet.Whether the connector supports network switching.
(networkChainId?: number | string) => Promise<void>
Available directly on the wallet object. Switch to another network by providing either the network name or chain id.
switchNetwork with a connector supporting network switching, the SDK will either request the user to confirm the network switch or add the network if it was not previously set.
Example
