useConnect
Hook for connecting to configured connectors.
import { useConnect } from 'wagmi'
Usage
import { useConnect } from 'wagmi'
const App = () => { const [{ data, error, loading }, connect] = useConnect()
return ( <> <div>Connected: {data.connected.toString()}</div>
{data.connectors.map((x) => ( <button key={x.name} onClick={() => connect(x)}> {x.name} </button> ))} </> )}
Return Values
state
{ data?: { connected: boolean connector: Connector connectors: Connector[] } error?: Error loading?: boolean}
connect
(connector: Connector) => Promise< | { connector: Connector data: { account?: string chainId?: number provider?: Provider } } | Error>