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'functionApp () {constconfig =useConfig ()}
ts
import {useConfig } from 'wagmi'functionApp () {constconfig =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(),
},
})
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(),
},
})