useConnectionStatus

Hook for checking whether your app is connected to a wallet or not.

Example

import { useConnectionStatus } from "@thirdweb-dev/react";
function App() {
const connectionStatus = useConnectionStatus();
if (connectionStatus === "unknown") return <p> Loading... </p>;
if (connectionStatus === "connecting")
return <p> Connecting... </p>;
if (connectionStatus === "connected")
return <p> You are connected </p>;
if (connectionStatus === "disconnected")
return <p> You are not connected to a wallet </p>;
}
function useConnectionStatus(): ConnectionStatus;

Returns

let returnType: "connected" | "disconnected" | "connecting";

The wallet connection status

It can be one of the following:

  • unknown : connection status is not known yet. This is the initial state.

  • connecting : wallet is being connected. Either because of a user action, or when the wallet is auto-connecting on page load.

  • connected : the wallet is connected and ready to be used.

  • disconnected : the wallet is not connected.