isConnected
Checks whether the user is currently connected to a wallet. A user is considered connected if at least one STX or BTC address has been cached in local storage from a previous connect or request call.
Usage
import { isConnected } from '@stacks/connect';
if (isConnected()) {
console.log('Wallet is connected');
} else {
console.log('No wallet connected');
}Notes
This function relies on local storage data. It will only return
trueifenableLocalStoragewastrue(the default) when the user connected.Calling
disconnectorclearLocalStoragewill cause this function to returnfalse.
Signature
function isConnected(): booleanReturns
boolean
Returns true if at least one STX or BTC address exists in the local storage cache. Returns false otherwise.
Parameters
This function takes no parameters.
Last updated
Was this helpful?