For the complete documentation index, see llms.txt. This page is also available as Markdown.

Connecting

Detect whether a user has Varial installed, check if your app is authorized, request access to the user's public key, and disconnect.

Detecting Varial

isConnected()

Check if the user has Varial installed in their browser.

Returns: Promise<{ isConnected: boolean } & { error?: FreighterApiError }>

import { isConnected } from "@stellar/varial-sdk";

const result = await isConnected();

if (result.isConnected) {
  console.log("Varial is installed");
}

isConnected() checks whether the Varial extension is installed. Note that it returns false for any user without the extension — not just mobile users. To detect the Varial mobile app's in-app browser specifically, check for window.stellar?.platform === "mobile". The injected window.stellar.provider value is still "freighter", the app's old name — it was kept unchanged so existing wallet detection keeps working.

Checking Authorization

isAllowed()

Check if the user has previously authorized your app to receive data from Varial.

Returns: Promise<{ isAllowed: boolean } & { error?: FreighterApiError }>

Requesting Authorization

setAllowed()

Prompt the user to authorize your app and add it to Varial's Allow List. Once approved, the extension can provide user data without additional prompts.

Returns: Promise<{ isAllowed: boolean } & { error?: FreighterApiError }>

If the user has already authorized your app, setAllowed() resolves immediately with { isAllowed: true }.

Requesting Access

requestAccess()

Prompt the user to add your dapp to Varial's Allow List and return their public key in one call. This is the recommended way to connect — it combines authorization and data retrieval in a single step.

Returns: Promise<{ address: string } & { error?: FreighterApiError }>

If the user has previously authorized your app, the public key is returned immediately without a popup.

Disconnecting

disconnect()

Revoke your app's access to the user's public key, for example from a "Disconnect" button in your app. Varial removes your app from the Allow List without asking the user to confirm, so the next call to requestAccess() or setAllowed() prompts the user again.

disconnect() is available in @stellar/varial-sdk 7.0.0 and later. @stellar/freighter-api 6.0.1 doesn't include it.

Returns: Promise<{ error?: FreighterApiError }>

Calling disconnect() when your app isn't on the Allow List succeeds without changing anything. It returns an error if the user locked Varial manually or hasn't unlocked it since the browser started (an automatic lock after inactivity doesn't block it), or if the user's extension is a version that doesn't support disconnect(). The method was added in version 5.50.0 of the extension (the first Varial release), so earlier versions return an error.

Next steps

Last updated

Was this helpful?