Skip to content

useChains

Composable for getting configured chains

Import

ts
import { useChains } from '@wagmi/vue'

Usage

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

const chains = useChains()
</script>
ts
import { http, createConfig } from '@wagmi/vue'
import { mainnet, sepolia } from '@wagmi/vue/chains'

export const config = createConfig({
  chains: [mainnet, sepolia],
  transports: {
    [mainnet.id]: http(),
    [sepolia.id]: http(),
  },
})

Parameters

ts
import { type UseChainsParameters } from '@wagmi/vue'

config

Config | undefined

Config to use instead of retrieving from the WagmiPlugin.

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

const chains = useChains({
  config, 
})
</script>
ts
import { http, createConfig } from '@wagmi/vue'
import { mainnet, sepolia } from '@wagmi/vue/chains'

export const config = createConfig({
  chains: [mainnet, sepolia],
  transports: {
    [mainnet.id]: http(),
    [sepolia.id]: http(),
  },
})

Return Type

ts
import { type UseChainsReturnType } from '@wagmi/vue'

readonly [Chain, ...Chain[]]

Chains from config.chains.

Action

Released under the MIT License.