clawchain/wagmi/site/vue/api/composables/useConnectorClient.md

2.6 KiB

title, description
title description
useConnectorClient Composable for getting a Viem `Client` object for the current or provided connector.

useConnectorClient

Composable for getting a Viem Client object for the current or provided connector.

Import

import { useConnectorClient } from '@wagmi/vue'

Usage

::: code-group

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

const result = useConnectorClient()
</script>

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

Parameters

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

account

Address | Account | undefined

Account to use with client. Throws if account is not found on connector.

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

const result = useConnectorClient({
  account: '0xd2135CfB216b74109775236E36d4b433F1DF507B', // [!code focus]
})
</script>

chainId

config['chains'][number]['id'] | undefined

ID of chain to use with client.

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

const result = useConnectorClient({
  chainId: mainnet.id, // [!code focus]
})
</script>

config

Config | undefined

Config to use instead of retrieving from the nearest WagmiProvider.

::: code-group

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

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

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

connector

Connector | undefined

  • Connector to get client for.
  • Defaults to current connector.
<script setup lang="ts">
import { useConnections, useConnectorClient } from '@wagmi/vue'

const connections = useConnections(config)
const result = useConnectorClient({
  connector: connections[0]?.connector, // [!code focus]
})
</script>

Return Type

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

Action