useStatus

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

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.

Last updated