clawchain/wagmi/site/react/api/hooks/useConnection.md

1.1 KiB

title, description
title description
useConnection Hook for getting current connection.

useConnection

Hook for getting current connection.

Import

import { useConnection } from 'wagmi'

Usage

::: code-group

import { useConnection } from 'wagmi'

function App() {
  const connection = useConnection()
}

<<< @/snippets/react/config.ts[config.ts] :::

Parameters

import { type UseConnectionParameters } from 'wagmi'

config

Config | undefined

Config to use instead of retrieving from the nearest WagmiProvider.

::: code-group

import { useConnection } from 'wagmi'
import { config } from './config' // [!code focus]

function App() {
  const connection = useConnection({
    config, // [!code focus]
  })
}

<<< @/snippets/react/config.ts[config.ts] :::

Return Type

import { type UseConnectionReturnType } from 'wagmi'

Action