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
| Property | Type | Description |
|---|---|---|
connection | Connection | The @solana/web3.js Connection instance |
Notes
- The
Connectionis created from theendpointpassed toWankmiProvider. - 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.