connect
Action for connecting to account with connectors.
import { connect } from '@wagmi/core'
Usage
import { connect } from '@wagmi/core'
import { InjectedConnector } from '@wagmi/core/connectors/injected'
const result = await connect({
connector: new InjectedConnector(),
})
Return Value
{
address: `0x${string}`
chain: {
id: number
unsupported?: boolean
}
connector: Connector
}
Configuration
chainId (optional)
Chain ID to connect.
import { connect } from '@wagmi/core'
import { optimism } from '@wagmi/core/chains'
import { InjectedConnector } from '@wagmi/core/connectors/injected'
const result = await connect({
chainId: optimism.id,
connector: new InjectedConnector(),
})
Note: The above example is using the optimism
chain from @wagmi/core/chains
.
connector
Connector to use for connecting wallet.
import { connect, InjectedConnector } from '@wagmi/core'
const result = await connect({
connector: new InjectedConnector(),
})