• React
  • Hooks
  • usePublicClient

usePublicClient

Hook for accessing viem's Public Client.

import { usePublicClient } from 'wagmi'

Usage

import { usePublicClient } from 'wagmi'
 
function App() {
  const publicClient = usePublicClient()
}

Return Value

PublicClient

Configuration

chainId (optional)

Force a specific chain id. The wagmi Client's publicClient must be set up as a chain-aware function for this to work correctly.

import { usePublicClient } from 'wagmi'
 
function App() {
  const publicClient = usePublicClient({
    chainId: 1,
  })
}