Skip to content

useConnections

Hook for getting active connections.

Import

ts
import { useConnections } from 'wagmi'
import { useConnections } from 'wagmi'

Usage

tsx
import { useConnections } from 'wagmi'

function App() {
  const connections = useConnections()
}
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(),
  },
})
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'
import { type UseConnectionsParameters } from 'wagmi'

config

Config | undefined

Config to use instead of retrieving from the from nearest WagmiProvider.

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

function App() {
  const connections = useConnections({
    config, 
  })
}
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(),
  },
})
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'
import { type UseConnectionsReturnType } from 'wagmi'

Action

Released under the MIT License.