Authento API
  • Welcome to Authento
  • Integration Guidance
    • Introduction
    • Address-Based Verification
      • Off-Chain Access Control
      • On-Chain Access Control
        • Digital Signature Verification
        • Merkel Proof Verification
    • Account-Based Verification
    • Webhooks
  • API Reference
    • General Information
    • Endpoints
      • Get Basic User Info
      • Get Full User Info
  • Authento-react
    • Getting Started
    • useSignature
    • useStatus
    • useTokenVerifyPopup
    • useVerifyPopup
Powered by GitBook
On this page
  • Usage
  • Configuration
  • Return Value
  1. Authento-react

useStatus

A custom React hook to fetch and manage user status from your backend for address-based verifications.

PrevioususeSignatureNextuseTokenVerifyPopup

Last updated 1 year ago

To make use of this hook, you must set up your own backend to handle status requests as described .

Usage

import { useStatus } from "authento-react";
  
export const MyComponent = () => {
  const { status, type, isLoading, refetch } = useStatus({
    endpoint: "https://api.example.com/status",
    refetchOnFocus: true
  });

  return (
    <div>
      <p>User Status: {isLoading ? "Loading..." : status}</p>
      <p>User Type: {isLoading ? "Loading..." : type}</p>
      <button onClick={refetch}>Refresh</button>
    </div>
  );
};

Configuration

The useStatus hook accepts a configuration object with the following options:

  • endpoint (required): Your own endpoint for user status.

  • refetchOnFocus (optional, default: true): A boolean value indicating whether to refetch the user status when the window gets focused.

Return Value

The useStatus hook returns an object with the following properties:

  • status: A string representing the user status. It will be undefined initially and will be updated with the fetched status when available.

  • type: A string representing the user type. It will be undefined initially and will be updated with the fetched user type when available.

  • isLoading: A boolean value indicating whether the data is being fetched from the endpoint.

  • refetch: A function that can be called to manually trigger a refetch of the user status.

here