The vagmi Client manages wallet connection state and configuration, such as: auto-connection, connectors, and ethers providers.
import { configureChains, createClient, defaultChains } from 'vagmi';import { publicProvider } from 'vagmi/providers/public';const { provider, webSocketProvider } = configureChains(defaultChains, [ publicProvider(),]);const client = createClient({ provider, webSocketProvider,});
Enables reconnecting to last used connector on mount. Defaults to false
.
import { configureChains, createClient, defaultChains } from 'vagmi';import { publicProvider } from 'vagmi/providers/public';const { provider } = configureChains(defaultChains, [ publicProvider(),]);const client = createClient({ autoConnect: true, provider,});
Connectors used for linking accounts. Defaults to [new InjectedConnector()]
.
import { configureChains, createClient, defaultChains } from 'vagmi';import { publicProvider } from 'vagmi/providers/public';import { InjectedConnector } from 'vagmi/connectors/injected';import { WalletConnectConnector } from 'vagmi/connectors/walletConnect';const { chains, provider } = configureChains(defaultChains, [publicProvider()]);const client = createClient({ connectors: [ new InjectedConnector({ chains }), new WalletConnectConnector({ chains, options: { qrcode: true, }, }), ], provider,});
ethers interface for connecting to the Ethereum network.
import { configureChains, createClient, defaultChains } from 'vagmi';import { publicProvider } from 'vagmi/providers/public';const { provider } = configureChains(defaultChains, [publicProvider()]);const client = createClient({ provider,});
ethers WebSocket interface for connecting to the Ethereum network. If you provide a WebSocket provider, it will be used instead of polling in certain instances.
import { configureChains, createClient, defaultChains } from 'vagmi';import { publicProvider } from 'vagmi/providers/public';const { provider, webSocketProvider } = configureChains(defaultChains, [ publicProvider(),]);const client = createClient({ provider, webSocketProvider,});