Skip to main content
createStable accepts a viem WalletClient, which is exactly what wagmi’s useWalletClient returns. You connect the wallet through wagmi as you normally would, then memoize a StableClient whenever the wallet client changes. This guide assumes wagmi v2 and @tanstack/react-query.

1. Configure wagmi

Add Stable to the wagmi config. viem ships chain definitions for both networks.

2. Build a hook that returns a StableClient

Memoize a StableClient against the current WalletClient. Recreate it when the wallet client identity changes.
useWalletClient() returns undefined before the user connects. Always guard before calling SDK methods, or the destructured walletClient will be falsy and createStable will not have a signer.

3. Use it in a component

4. Bridge and swap from React

The same stable instance handles bridge and swap. Fetch the quote in an effect or a useQuery, then execute on click.
Caching quotes with useQuery works well: pass quoteSwap / quoteBridge as the query function and forward the cached quote into swap / bridge. The SDK skips its internal quote call when one is provided.

SDK reference

Every method, config field, and error class.

Use with viem

Compare the three signing modes side-by-side.

SDK quickstart

Run your first transfer, bridge, and swap on testnet.
Last modified on May 11, 2026