useClient
Hook for getting Client
instance.
Import
import { useClient } from "starkweb/react"
Usage
index.tsx
import { useClient } from "starkweb/react"
function App() {
const client = useClient()
}
Parameters
import { type UseClientParameters } from "starkweb/react"
chainId
config["chains"][number]["id"] | undefined
ID of chain to use when getting Client
.
index.ts
import { useClient } from "starkweb/react"
import { mainnet } from "starkweb/react/chains"
function App() {
const client = useClient({
chainId: mainnet.chain_id,
})
}
config
Config | undefined
Config
to use instead of retrieving from the nearest StarkwebProvider
.
index.tsx
import { useClient } from "starkweb/react"
import { config } from "./config"
function App() {
const client = useClient({
config,
})
}
Return Type
import { type UseClientReturnType } from "starkweb/react"
Client | undefined
Client
instance.