HooksuseAgent

useAgent

Hook to get identityKitAgent, which manages when to show approval pop-ups to make canister calls or not, it uses built-in signerAgent to show pop-ups and dfinity HttpAgent with identity from identitykit otherwise.

Return values

Agent|undefined

ℹ️

Retrieved agent will be undefined until user is connected and agent is created under the hood

Usage

import { useAgent } from "@nfid/identitykit/react"
const agent = useAgent()

Or with your custom options:

import { useAgent } from "@nfid/identitykit/react"
const agent = useAgent({ retryTimes: 1 })
⚠️

By default global ic network will be used, to change it as well as other agent settings provide options to hook

Read more about agents usage.