Connection Status
- React
- React-Native
- Unity
- Unity
useConnectionStatus
Hook for checking whether your app is connected to a wallet.
import { useConnectionStatus } from "@thirdweb-dev/react";
Usage
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>;
}
Return Value
Return Value
unknown
: Application has not yet determined connection status.connecting
: Application is trying to connect to a wallet. Either because of a user action, or when autoconnect set totrue
.connected
: Application is connected to a wallet.disconnected
: Application is not connected to any wallet.
"unknown" | "connecting" | "connected" | "disconnected";
useConnectionStatus
Hook for checking whether your app is connected to a wallet.
import { useConnectionStatus } from "@thirdweb-dev/react-native";
Usage
import { useConnectionStatus } from "@thirdweb-dev/react-native";
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>;
}
Return Value
Return Value
unknown
: Application has not yet determined connection status.connecting
: Application is trying to connect to a wallet. Either because of a user action, or when autoconnect set totrue
.connected
: Application is connected to a wallet.disconnected
: Application is not connected to any wallet.
"unknown" | "connecting" | "connected" | "disconnected";
isConnected
Check whether there's a signer connected with the SDK.
Usage
Call this method to check if a signer (e.g. a wallet) is connected to the SDK.
if (sdk.wallet.isConnected()) {
// a signer is connected!
// perform some logic
} else {
// no signer is connected
// perform some other logic
}
Return Value
Returns true
if a signer is connected, false
if not.
boolean;