2.0 KiB

title, description
title description
useConnect Composable for connecting accounts with connectors.

useConnect

Composable for connecting accounts with connectors.

Import

import { useConnect } from '@wagmi/vue'

Usage

::: code-group

<script setup lang="ts">
import { useConnect } from '@wagmi/vue'
import { injected } from '@wagmi/connectors'

const connect = useConnect()
</script>

<template>
  <button @click="connect.mutate({ connector: injected() })">
    Connect
  </button>
</template>

<<< @/snippets/vue/config.ts[config.ts] :::

Parameters

import { type UseConnectParameters } from '@wagmi/vue'

config

Config | undefined

Config to use instead of retrieving from the WagmiPlugin.

::: code-group

<script setup lang="ts">
import { useConnect } from '@wagmi/vue'
import { config } from './config' // [!code focus]

const connect = useConnect({
  config, // [!code focus]
})
</script>

<<< @/snippets/vue/config.ts[config.ts] :::

Return Type

import { type UseConnectReturnType } from '@wagmi/vue'

::: tip Not all connectors support connecting directly to a chainId (e.g. they don't support programmatic chain switching). In those cases, the connector will connect to whatever chain the connector's provider (e.g. wallet) is connected to. :::

Action