Skip to content

useConfig

Hook for getting Config from nearest WagmiProvider.

Import

ts
import { useConfig } from 'wagmi'
import { useConfig } from 'wagmi'

Usage

tsx
import { useConfig } from 'wagmi'

function App() {
  const config = useConfig()
}
import { useConfig } from 'wagmi'

function App() {
  const config = useConfig()
}

Return Type

ts
import { type UseConfigReturnType } from 'wagmi'
import { type UseConfigReturnType } from 'wagmi'

If you use TypeScript and register your Config, the return type will be inferred.

ts
ts
import { useConfig } from 'wagmi'
 
function App() {
const config = useConfig()
const config: Config<readonly [{ blockExplorers: { readonly default: { readonly name: "Etherscan"; readonly url: "https://etherscan.io"; }; }; contracts: { readonly ensRegistry: { readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"; }; readonly ensUniversalResolver: { ...; }; readonly multicall3: { ...; }; }; ... 8 more ...; fees?: ChainFees<...> | undefined; }, { ...; }]>
}
ts
import { useConfig } from 'wagmi'
 
function App() {
const config = useConfig()
const config: Config<readonly [{ blockExplorers: { readonly default: { readonly name: "Etherscan"; readonly url: "https://etherscan.io"; }; }; contracts: { readonly ensRegistry: { readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"; }; readonly ensUniversalResolver: { ...; }; readonly multicall3: { ...; }; }; ... 8 more ...; fees?: ChainFees<...> | undefined; }, { ...; }]>
}
ts
import { createConfig, http } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'

declare module 'wagmi' {
  interface Register {
    config: typeof config
  }
}

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

declare module 'wagmi' {
  interface Register {
    config: typeof config
  }
}

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

Released under the MIT License.