1.9 KiB
1.9 KiB
title, description
| title | description |
|---|---|
| useConnection | Primitive for getting current connection. |
useConnection
Primitive for getting current connection.
Import
import { useConnection } from '@wagmi/solid'
Usage
::: code-group
import { useConnection } from '@wagmi/solid'
import { Show } from 'solid-js'
function App() {
const connection = useConnection()
return (
<Show when={connection.isConnected} fallback={<p>Not connected</p>}>
<p>Address: {connection.address}</p>
<p>Chain ID: {connection.chainId}</p>
</Show>
)
}
<<< @/snippets/solid/config.ts[config.ts] :::
Parameters
import { useConnection } from '@wagmi/solid'
useConnection.Parameters
useConnection.SolidParameters
Parameters are passed as a getter function to maintain Solid reactivity.
useConnection(() => ({
config,
}))
config
Config | undefined
Config to use instead of retrieving from the nearest WagmiProvider.
Return Type
import { useConnection } from '@wagmi/solid'
useConnection.ReturnType
address
Address | undefined
The connected account address.
addresses
readonly Address[] | undefined
All connected account addresses.
chain
Chain | undefined
The connected chain.
chainId
number | undefined
The connected chain ID.
connector
Connector | undefined
The active connector.
isConnected
boolean
Whether an account is connected.
isConnecting
boolean
Whether a connection is in progress.
isDisconnected
boolean
Whether the account is disconnected.
isReconnecting
boolean
Whether a reconnection is in progress.
status
'connected' | 'connecting' | 'disconnected' | 'reconnecting'
The current connection status.