React Reference


useYagna is a hook that provides information about the Yagna connection status. If the connection cannot be established, the hook will retry using an exponential backoff algorithm. It returns an object with the following properties:

isConnectedBoolean indicating whether the connection to Yagna is established.
isLoadingBoolean indicating whether the connection to Yagna is being established.
errorError object containing information about the error that occurred while connecting to Yagna.
reconnectA function that can be used to reconnect to Yagna.
setYagnaOptionsA function that can be used to set the app-key and base path for Yagna.
isAppKeySetBoolean indicating whether the app-key for Yagna is set.
appKeyThe current app-key for Yagna.
basePathThe current url for Yagna.


This hook doesn't accept any parameters.


function MyComponent() {
  const { isConnected, appKey, setYagnaOptions } = useYagna()
  const inputRef = useRef(null)
  return (
      <div>Connected to Yagna: {isConnected ? 'yes' : 'no'}</div>
      <input ref={inputRef} />
        onClick={() => setYagnaOptions({ apiKey: inputRef.current.value })}
        Set app key

Was this helpful?