Skip to content
Blog

SDK Reference

Full reference for every method and type in the Tribe SDK (@tribecloud/sdk).

Script tag:

<script src="https://api.tribe.utopian.build/sdk.js?site=YOUR_SITE_ID" defer></script>

npm:

Terminal window
npm install @tribecloud/sdk
import { Tribe } from "@tribecloud/sdk";
const tribe = new Tribe({ siteId: "YOUR_SITE_ID" });

interface TribeConfig {
siteId: string;
autoTrack?: boolean; // defaults to true
}

Create a new user account. Automatically stores the session and user tokens.

const { user, userToken } = await tribe.register(email: string, password: string);

Returns: { user: User, userToken?: string | null, sessionVerified?: boolean }

Throws if the email is already registered or the password fails breached password checks.


Sign in an existing user. Automatically stores the session and user tokens.

const { user, userToken, sessionVerified } = await tribe.login(email: string, password: string);

Returns: { user: User, userToken?: string | null, sessionVerified?: boolean }


End the current session and clear all stored tokens.

await tribe.logout();

Returns the current session if the user is logged in, or null otherwise. Also refreshes the user token.

const session = await tribe.getSession();

Returns: { user: User, userToken?: string | null, sessionVerified?: boolean } | null

Returns null if not logged in.


Retrieve the stored user token (JWT) for sending to your backend.

const token = tribe.getUserToken();

Returns: string | null


Fetch the authentication configuration for this site.

const config = await tribe.getAuthConfig();

Returns: AuthConfig


Navigate the user to Tribe’s hosted login page.

tribe.redirectToLogin();
tribe.redirectToLogin({ redirectUrl: "https://myapp.com/dashboard" });

Parameters:

  • options.redirectUrl — where to redirect after login (default: current page)

Navigate the user to Tribe’s hosted registration page.

tribe.redirectToRegister();
tribe.redirectToRegister({ redirectUrl: "https://myapp.com/onboarding" });

Navigate to a social login provider’s OAuth consent screen.

tribe.redirectToSocialLogin("google");
tribe.redirectToSocialLogin("github", { redirectUrl: "https://myapp.com/dashboard" });

Parameters:

  • provider"google" | "github" | "discord" | "twitter"
  • options.redirectUrl — where to redirect after login

Returns whether the browser supports WebAuthn passkeys.

const available = tribe.isPasskeyAvailable();

Returns: boolean


Authenticate using a registered passkey. Prompts the browser’s passkey dialog (fingerprint, Face ID, security key).

const { user, userToken, sessionVerified } = await tribe.loginWithPasskey();

Returns: { user: User, userToken?: string | null, sessionVerified?: boolean }

Throws if the browser doesn’t support WebAuthn, the user cancels, or passkey login is disabled.


Register a passkey for the currently authenticated user. Requires authentication.

await tribe.registerPasskey("My laptop");

List all registered passkeys for the current user. Requires authentication.

const passkeys = await tribe.getPasskeys();

Returns: PasskeyCredential[]


Remove a registered passkey.

await tribe.deletePasskey(id: string);

Check whether the current session has been verified. Returns true if verified or if suspicious login protection is not enabled.

const verified = await tribe.isSessionVerified();

Returns: boolean


Perform step-up authentication by prompting the user’s passkey. Marks the session as verified on success.

await tribe.verifySession();

Throws if the browser doesn’t support WebAuthn, the user has no passkeys, or the user cancels.


Returns whether a supported Solana wallet (Phantom, Backpack, or Solflare) is installed in the browser.

const available = tribe.isWalletAvailable();

Returns: boolean


Returns all Solana wallets detected in the browser.

const wallets = tribe.detectWallets();

Returns: DetectedWallet[] — e.g. [{ id: "phantom", name: "Phantom" }]


Authenticate using a Solana wallet via Sign-in-with-Solana. Connects to the first detected wallet.

const { user, userToken, sessionVerified } = await tribe.loginWithWallet();

Returns: { user: User, userToken?: string | null, sessionVerified?: boolean }

Throws if no wallet is installed, the user rejects the signature, or wallet login is disabled.


Authenticate with Google via Google Identity Services. Privacy-preserving: the server never stores the raw Google identity.

const { user, userToken, sessionVerified } = await tribe.loginWithGoogle();

Returns: { user: User, userToken?: string | null, sessionVerified?: boolean }

Requires zkGoogleEnabled and googleClientId in the site config.


Send a magic link to the given email address.

await tribe.requestMagicLink("[email protected]");
await tribe.requestMagicLink("[email protected]", { magicLinkUrl: "https://myapp.com/magic" });

Validate a magic link token and create a session.

const { user, userToken } = await tribe.verifyMagicLink(token: string);

Confirm an email address using the token from the verification email.

await tribe.verifyEmail(token: string);

Send the verification email again.

await tribe.resendVerification();
await tribe.resendVerification({ verifyEmailUrl: "https://myapp.com/verify" });

Trigger a password reset email.

await tribe.forgotPassword("[email protected]");
await tribe.forgotPassword("[email protected]", { resetPasswordUrl: "https://myapp.com/reset" });

Set a new password using the token from the reset email.

await tribe.resetPassword(token: string, newPassword: string);

Attach a Solana wallet to the current account as a recovery method.

const credentials = await tribe.linkWallet();

Returns: LinkedCredential[] — updated list of all linked credentials.


Attach a Google identity (privacy-preserving) to the current account.

const credentials = await tribe.linkGoogle();

Returns: LinkedCredential[]


Redirect to link an OAuth provider to the current account.

tribe.linkOAuth("github");

Navigates away and back. Check for ?tribe_linked=provider in the URL on return.


Remove a linked credential from the current account.

const credentials = await tribe.unlinkCredential(credentialId: string);

Returns: LinkedCredential[]

Throws if removing it would leave the account with no recovery method.


Retrieve all linked credentials for the current account.

const credentials = await tribe.getLinkedCredentials();

Returns: LinkedCredential[]


Record a custom event. Fire-and-forget; uses sendBeacon internally so it won’t block the page.

tribe.track("purchase", { productId: "abc", amount: 29.99 });

Parameters:

  • eventName — event name (string)
  • data — optional data object

Returns: void (synchronous)


Check whether a feature flag is enabled for the current context.

const enabled = await tribe.getFeatureFlag("new-checkout");

Returns: booleanfalse if the flag doesn’t exist.


Fetch active announcements, automatically filtering out any the user has already dismissed.

const announcements = await tribe.getAnnouncements();

Returns: Announcement[]


Mark an announcement as dismissed for the current user.

await tribe.ackAnnouncement(announcementId: string);

Submit user feedback to the dashboard.

await tribe.feedback("Great app!", { type: "general", email: "[email protected]" });

Parameters:

  • message — feedback text
  • options.type"bug" | "feature-request" | "general" (optional)
  • options.email — email for follow-up (optional)

List all active sessions and devices for the current user.

const devices = await tribe.getActiveDevices();

Returns: ActiveDevice[]


Terminate a specific session by ID.

await tribe.revokeSession(sessionId: string);

Destroy all sessions for the current user, effectively logging them out everywhere.

await tribe.invalidateAllSessions();

Create a new API key. The full key is only returned once.

const result = await tribe.createApiKey("My Key", ["read", "write"]);

Returns: ApiKeyResult{ id, key, name, scopes }


Retrieve all API keys belonging to the current user.

const keys = await tribe.listApiKeys();

Returns: ApiKey[]{ id, name, keyPrefix, scopes, createdAt }


Permanently delete an API key.

await tribe.deleteApiKey(id: string);

Assign a role to the current user.

const user = await tribe.setRole("admin");

Returns: User


Retrieve the site’s payment configuration.

const config = await tribe.getPaymentConfig();

Returns: PaymentConfig{ paymentsEnabled, p2pPaymentsEnabled, p2pFeeRate, paymentWalletAddress, acceptedTokens }


Create a payment and get back a Solana Pay URL.

const payment = await tribe.getPaymentUrl({
mint: "SOL",
amount: "0.5",
memo: "Order #123",
metadata: { orderId: "abc" },
recipientWallet: "...", // for P2P payments
});

Returns: PaymentResult{ id, paymentUrl, expiresAt }


Create a payment and render a branded QR code into a DOM container.

const payment = await tribe.renderPaymentQrCode({
mint: "SOL",
amount: "0.5",
container: document.getElementById("qr"),
width: 300,
height: 300,
});

Returns: PaymentResult


Complete a payment using the user’s browser wallet. Handles connection, signing, submission, and on-chain verification.

const status = await tribe.sendViaWallet({
mint: "SOL",
amount: "0.5",
});

Returns: PaymentStatus{ status: "pending" | "confirmed" | "expired", txSignature }


Poll the status of an existing payment.

const status = await tribe.verifyPayment(paymentId);

Returns: PaymentStatus


Use sendViaWallet() instead.


Fetch all available subscription tiers for the site. Does not require authentication.

const tiers = await tribe.getSubscriptions();

Returns: SubscriptionTier[]{ id, name, intervalDays, prices: [{ mint, amount }] }


Fetch the current user’s active subscriptions. Requires authentication.

const subs = await tribe.getActiveSubscriptions();

Returns: UserSubscription[]{ id, tier, startsAt, expiresAt, isActive }


Start a subscription purchase. Returns a payment that you complete via wallet or QR.

const payment = await tribe.purchaseSubscription(tierId, "SOL");

Returns: PaymentResult


interface User {
id: string;
email?: string | null;
pseudonymousId?: string;
authMethod?: string;
walletAddress?: string | null;
}
interface AuthConfig {
authEnabled: boolean;
accessMode: string; // "public" | "internal"
magicLinkEnabled: boolean;
captchaEnabled: boolean;
captchaProvider: string | null;
captchaSiteKey: string | null;
captchaRequiredForRegistration: boolean;
captchaRequiredForLogin: boolean;
breachedPasswordPolicy: string;
googleEnabled: boolean;
githubEnabled: boolean;
discordEnabled: boolean;
twitterEnabled: boolean;
walletLoginEnabled: boolean;
zkGoogleEnabled: boolean;
passkeyEnabled: boolean;
suspiciousLoginProtection: boolean;
googleClientId: string | null;
}
interface Announcement {
id: string;
title: string;
message: string;
type: string;
}
interface ActiveDevice {
id: string;
browser: string;
os: string;
deviceType: string;
lastActiveAt: string;
createdAt: string;
isCurrent: boolean;
}
interface ApiKey {
id: string;
name: string;
keyPrefix: string;
scopes: string[];
createdAt: string;
}
interface ApiKeyResult {
id: string;
key: string; // full key — only returned from createApiKey()
name: string;
scopes: string[];
}
interface PasskeyCredential {
id: string;
deviceName: string | null;
transports: string[];
createdAt: string;
}
interface LinkedCredential {
id: string;
provider: string; // "wallet" | "google" | "github" | "discord" | "twitter"
walletAddress?: string | null; // only for wallet credentials
createdAt: string;
}
interface DetectedWallet {
id: string; // "phantom" | "backpack" | "solflare"
name: string; // "Phantom" | "Backpack" | "Solflare"
}
interface PaymentOptions {
mint: string; // "SOL" or SPL token mint address
amount: string; // human-readable, e.g. "2.5"
memo?: string;
metadata?: Record<string, unknown>;
recipientWallet?: string; // for P2P payments
}
interface PaymentResult {
id: string; // payment ID for verification
paymentUrl: string; // Solana Pay URL
expiresAt: string; // expires after 10 minutes
}
interface PaymentStatus {
status: "pending" | "confirmed" | "expired";
txSignature: string | null;
}
interface PaymentConfig {
paymentsEnabled: boolean;
p2pPaymentsEnabled: boolean;
p2pFeeRate: number;
paymentWalletAddress: string | null;
acceptedTokens: AcceptedToken[];
}
interface AcceptedToken {
mint: string;
symbol: string;
name: string;
logoUrl: string | null;
decimals: number;
}
interface RenderQrCodeOptions extends PaymentOptions {
container: HTMLElement;
width?: number; // default 300
height?: number; // default 300
}
interface SubscriptionTier {
id: string;
name: string;
prices: SubscriptionTierPrice[];
intervalDays: number;
}
interface SubscriptionTierPrice {
mint: string;
amount: string;
}
interface UserSubscription {
id: string;
tier: SubscriptionTier;
startsAt: string;
expiresAt: string;
isActive: boolean;
}
interface RedirectOptions {
redirectUrl?: string;
}
interface FeedbackOptions {
type?: string;
email?: string;
}
interface ForgotPasswordOptions {
resetPasswordUrl?: string;
}
interface ResendVerificationOptions {
verifyEmailUrl?: string;
}
interface MagicLinkOptions {
magicLinkUrl?: string;
}
type SocialProvider = "google" | "github" | "discord" | "twitter";