Skip to content

watchConnectors

Subscribe to connectors changes.

Import

ts
import { watchConnectors } from '@wagmi/core'

Usage

ts
import { watchConnectors } from '@wagmi/core'
import { config } from './config'

const unwatch = watchConnectors(config, {
  onChange(connectors) {
    console.log('Connectors changed!', connectors)
  },
})
unwatch()
ts
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'

export const config = createConfig({
  chains: [mainnet, sepolia],
  transports: {
    [mainnet.id]: http(),
    [sepolia.id]: http(),
  },
})

Parameters

ts
import { type WatchConnectorsParameters } from '@wagmi/core'

onChange

onChange(connectors: GetConnectorsReturnType, prevConnectors: GetConnectorsReturnType): void

Callback function called when connectors changes.

ts
import { watchConnectors } from '@wagmi/core'
import { config } from './config'

const unwatch = watchConnectors(config, {
  onChange(connectors) { 
    console.log('Connectors changed!', connectors)
  },
})
unwatch()
ts
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'

export const config = createConfig({
  chains: [mainnet, sepolia],
  transports: {
    [mainnet.id]: http(),
    [sepolia.id]: http(),
  },
})

Return Type

ts
import { type WatchConnectorsReturnType } from '@wagmi/core'

Function for cleaning up watcher.

Released under the MIT License.