- Setting the default network at startup
- Switching networks at runtime using the
useNetworkhook/composable/primitive
Default network
When initializing the WalletManager, you can specify which network to use as the default:resetNetwork option:
resetNetwork is false (the default), use-wallet will attempt to restore the last active network from local storage.
Runtime network switching
TheuseNetwork hook/composable provides methods for switching networks at runtime.
Network status
You can use theactiveNetworkConfig to access information about the current network:
Network events
When switching networks, several things happen automatically:- The
algodClientis updated to point to the new network - Active wallet sessions are maintained (if the wallet supports the new network)
- The active network is saved to local storage
Wallet compatibility
Not all wallets support all networks. For example:- Exodus only works on MainNet
- Defly and Pera only support MainNet and TestNet
- The Mnemonic wallet only works on test networks
- Custom networks may not be supported by all wallets
Default networks
use-wallet supports any AVM-compatible network and comes with default configurations for these Algorand networks:- MainNet
- TestNet
- BetaNet
- LocalNet (for development)