Hooks
useConnection

useConnection

Access the Solana Connection instance configured in WankmiProvider.

Import

import { useConnection } from '@wankmi/wankmi'

Usage

import { useConnection } from '@wankmi/wankmi'
 
function SlotNumber() {
  const { connection } = useConnection()
  const [slot, setSlot] = React.useState<number | null>(null)
 
  React.useEffect(() => {
    connection.getSlot().then(setSlot)
  }, [connection])
 
  return <p>Current slot: {slot}</p>
}

Return Value

PropertyTypeDescription
connectionConnectionThe @solana/web3.js Connection instance

Notes

  • The Connection is created from the endpoint passed to WankmiProvider.
  • You typically won't need this hook directly — the data hooks (useSolBalance, useTokenAccounts, etc.) use it internally.
  • Use this hook when you need raw access to the RPC, e.g. subscribing to account changes or fetching data not covered by a dedicated hook.