• React
  • Hooks
  • useWebSocketPublicClient

useWebSocketPublicClient

Hook for accessing viem's WebSocket Public Client.

import { useWebSocketPublicClient } from 'wagmi'

Usage

import { useWebSocketPublicClient } from 'wagmi'
 
function App() {
  const webSocketPublicClient = useWebSocketPublicClient()
}

Return Value

WebSocketPublicClient

Configuration

chainId (optional)

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

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