• React
  • Hooks
  • useWebSocketProvider

useWebSocketProvider

Hook for accessing the Client's ethers WebSocket Provider.

import { useWebSocketProvider } from 'wagmi'

Usage

import { useWebSocketProvider } from 'wagmi'
 
function App() {
  const webSocketProvider = useWebSocketProvider()
}

Return Value

WebSocketProvider

Configuration

chainId (optional)

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

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