Skip to content

useConnections

Hook for getting active connections.

Import

ts
import { useConnections } from 'wagmi'

Usage

tsx
import { useConnections } from 'wagmi'

function App() {
  const connections = useConnections()
}
ts
import { http, createConfig } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'

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

Parameters

ts
import { type UseConnectionsParameters } from 'wagmi'

config

Config | undefined

Config to use instead of retrieving from the nearest WagmiProvider.

tsx
import { useConnections } from 'wagmi'
import { config } from './config'

function App() {
  const connections = useConnections({
    config,
  })
}
ts
import { http, createConfig } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'

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

Return Type

ts
import { type UseConnectionsReturnType } from 'wagmi'

Action

Released under the MIT License.