Skip to content

useConfig

Hook for getting Config from nearest WagmiProvider.

Import

ts
import { useConfig } from 'wagmi'

Usage

tsx
import { useConfig } from 'wagmi'

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

Return Type

ts
import { type UseConfigReturnType } from 'wagmi'

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

ts
import { 
useConfig
} from 'wagmi'
function
App
() {
const
config
=
useConfig
()
}
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(),
  },
})

Released under the MIT License.