Skip to content

useChains

Primitive for getting configured chains.

Import

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

Usage

tsx
import { useChains } from '@wagmi/solid'
import { For } from 'solid-js'

function App() {
  const chains = useChains()
  
  return (
    <ul>
      <For each={chains()}>
        {(chain) => <li>{chain.name}</li>}
      </For>
    </ul>
  )
}
ts
import { createConfig, http } from '@wagmi/solid'
import { mainnet, sepolia } from '@wagmi/solid/chains'

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

Parameters

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

useChains.Parameters
useChains.SolidParameters

Parameters are passed as a getter function to maintain Solid reactivity.

ts
useChains(() => ({
  config,
}))

config

Config | undefined

Config to use instead of retrieving from the nearest WagmiProvider.

Return Type

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

useChains.ReturnType

Accessor<readonly Chain[]>

Returns an accessor containing the configured chains.

Action

Released under the MIT License.