@txnlab/use-wallet-svelte package provides Svelte-specific bindings for use-wallet, including context management and reactive stores that enable seamless wallet integration in Svelte applications.
Installation
- npm
- yarn
- pnpm
Setup
Configure wallet context
Create aWalletManager instance and initialize the wallet context using useWalletContext. This is typically done in your root layout component.
Using the wallet hook
TheuseWallet function provides reactive access to wallet state and signing methods. Returned stores use Svelte’s reactive .current property.
Basic usage
Return values
TheuseWallet function returns reactive stores and methods:
Wallet interface
Each wallet object has the following properties:Signing transactions
ThetransactionSigner method is compatible with the Algorand SDK’s AtomicTransactionComposer.
Network management
TheuseNetwork function provides methods for managing network configuration.
Return values
Managing accounts
Switch between accounts for a connected wallet:Working with multiple wallets
Iterate through wallets and manage their connection states:Signing arbitrary data
For wallets that support it, you can sign arbitrary data for authentication:Accessing the wallet manager
For advanced use cases, access the wallet manager directly:TypeScript support
The package includes full TypeScript definitions:SvelteKit integration
For SvelteKit applications, initialize the wallet context in your root+layout.svelte file:
Next steps
Configuration
Learn about wallet and network configuration options
Wallets
Explore supported wallet providers and their options