SDK Reference
Full reference for every method and type in the Tribe SDK (@tribecloud/sdk).
Installation
Section titled “Installation”Script tag:
<script src="https://api.tribe.utopian.build/sdk.js?site=YOUR_SITE_ID" defer></script>npm:
npm install @tribecloud/sdkimport { Tribe } from "@tribecloud/sdk";const tribe = new Tribe({ siteId: "YOUR_SITE_ID" });Configuration
Section titled “Configuration”interface TribeConfig { siteId: string; autoTrack?: boolean; // defaults to true}Authentication
Section titled “Authentication”register(email, password)
Section titled “register(email, password)”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.
login(email, password)
Section titled “login(email, password)”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 }
logout()
Section titled “logout()”End the current session and clear all stored tokens.
await tribe.logout();getSession()
Section titled “getSession()”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.
getUserToken()
Section titled “getUserToken()”Retrieve the stored user token (JWT) for sending to your backend.
const token = tribe.getUserToken();Returns: string | null
getAuthConfig()
Section titled “getAuthConfig()”Fetch the authentication configuration for this site.
const config = await tribe.getAuthConfig();Returns: AuthConfig
Hosted Auth Pages
Section titled “Hosted Auth Pages”redirectToLogin(options?)
Section titled “redirectToLogin(options?)”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)
redirectToRegister(options?)
Section titled “redirectToRegister(options?)”Navigate the user to Tribe’s hosted registration page.
tribe.redirectToRegister();tribe.redirectToRegister({ redirectUrl: "https://myapp.com/onboarding" });redirectToSocialLogin(provider, options?)
Section titled “redirectToSocialLogin(provider, options?)”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
Passkey Login
Section titled “Passkey Login”isPasskeyAvailable()
Section titled “isPasskeyAvailable()”Returns whether the browser supports WebAuthn passkeys.
const available = tribe.isPasskeyAvailable();Returns: boolean
loginWithPasskey()
Section titled “loginWithPasskey()”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.
registerPasskey(deviceName?)
Section titled “registerPasskey(deviceName?)”Register a passkey for the currently authenticated user. Requires authentication.
await tribe.registerPasskey("My laptop");getPasskeys()
Section titled “getPasskeys()”List all registered passkeys for the current user. Requires authentication.
const passkeys = await tribe.getPasskeys();Returns: PasskeyCredential[]
deletePasskey(id)
Section titled “deletePasskey(id)”Remove a registered passkey.
await tribe.deletePasskey(id: string);Session Verification
Section titled “Session Verification”isSessionVerified()
Section titled “isSessionVerified()”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
verifySession()
Section titled “verifySession()”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.
Wallet Login
Section titled “Wallet Login”isWalletAvailable()
Section titled “isWalletAvailable()”Returns whether a supported Solana wallet (Phantom, Backpack, or Solflare) is installed in the browser.
const available = tribe.isWalletAvailable();Returns: boolean
detectWallets()
Section titled “detectWallets()”Returns all Solana wallets detected in the browser.
const wallets = tribe.detectWallets();Returns: DetectedWallet[] — e.g. [{ id: "phantom", name: "Phantom" }]
loginWithWallet()
Section titled “loginWithWallet()”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.
loginWithGoogle()
Section titled “loginWithGoogle()”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.
Magic Links
Section titled “Magic Links”requestMagicLink(email, options?)
Section titled “requestMagicLink(email, options?)”Send a magic link to the given email address.
verifyMagicLink(token)
Section titled “verifyMagicLink(token)”Validate a magic link token and create a session.
const { user, userToken } = await tribe.verifyMagicLink(token: string);Email Verification
Section titled “Email Verification”verifyEmail(token)
Section titled “verifyEmail(token)”Confirm an email address using the token from the verification email.
await tribe.verifyEmail(token: string);resendVerification(options?)
Section titled “resendVerification(options?)”Send the verification email again.
await tribe.resendVerification();await tribe.resendVerification({ verifyEmailUrl: "https://myapp.com/verify" });Password Reset
Section titled “Password Reset”forgotPassword(email, options?)
Section titled “forgotPassword(email, options?)”Trigger a password reset email.
resetPassword(token, newPassword)
Section titled “resetPassword(token, newPassword)”Set a new password using the token from the reset email.
await tribe.resetPassword(token: string, newPassword: string);Account Linking
Section titled “Account Linking”linkWallet()
Section titled “linkWallet()”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.
linkGoogle()
Section titled “linkGoogle()”Attach a Google identity (privacy-preserving) to the current account.
const credentials = await tribe.linkGoogle();Returns: LinkedCredential[]
linkOAuth(provider)
Section titled “linkOAuth(provider)”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.
unlinkCredential(credentialId)
Section titled “unlinkCredential(credentialId)”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.
getLinkedCredentials()
Section titled “getLinkedCredentials()”Retrieve all linked credentials for the current account.
const credentials = await tribe.getLinkedCredentials();Returns: LinkedCredential[]
Analytics
Section titled “Analytics”track(eventName, data?)
Section titled “track(eventName, data?)”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)
Feature Flags
Section titled “Feature Flags”getFeatureFlag(key)
Section titled “getFeatureFlag(key)”Check whether a feature flag is enabled for the current context.
const enabled = await tribe.getFeatureFlag("new-checkout");Returns: boolean — false if the flag doesn’t exist.
Announcements
Section titled “Announcements”getAnnouncements()
Section titled “getAnnouncements()”Fetch active announcements, automatically filtering out any the user has already dismissed.
const announcements = await tribe.getAnnouncements();Returns: Announcement[]
ackAnnouncement(announcementId)
Section titled “ackAnnouncement(announcementId)”Mark an announcement as dismissed for the current user.
await tribe.ackAnnouncement(announcementId: string);Feedback
Section titled “Feedback”feedback(message, options?)
Section titled “feedback(message, options?)”Submit user feedback to the dashboard.
Parameters:
message— feedback textoptions.type—"bug" | "feature-request" | "general"(optional)options.email— email for follow-up (optional)
Session & Device Management
Section titled “Session & Device Management”getActiveDevices()
Section titled “getActiveDevices()”List all active sessions and devices for the current user.
const devices = await tribe.getActiveDevices();Returns: ActiveDevice[]
revokeSession(sessionId)
Section titled “revokeSession(sessionId)”Terminate a specific session by ID.
await tribe.revokeSession(sessionId: string);invalidateAllSessions()
Section titled “invalidateAllSessions()”Destroy all sessions for the current user, effectively logging them out everywhere.
await tribe.invalidateAllSessions();API Keys
Section titled “API Keys”createApiKey(name, scopes)
Section titled “createApiKey(name, scopes)”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 }
listApiKeys()
Section titled “listApiKeys()”Retrieve all API keys belonging to the current user.
const keys = await tribe.listApiKeys();Returns: ApiKey[] — { id, name, keyPrefix, scopes, createdAt }
deleteApiKey(id)
Section titled “deleteApiKey(id)”Permanently delete an API key.
await tribe.deleteApiKey(id: string);User Roles
Section titled “User Roles”setRole(role)
Section titled “setRole(role)”Assign a role to the current user.
const user = await tribe.setRole("admin");Returns: User
Payments
Section titled “Payments”getPaymentConfig()
Section titled “getPaymentConfig()”Retrieve the site’s payment configuration.
const config = await tribe.getPaymentConfig();Returns: PaymentConfig — { paymentsEnabled, p2pPaymentsEnabled, p2pFeeRate, paymentWalletAddress, acceptedTokens }
getPaymentUrl(options)
Section titled “getPaymentUrl(options)”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 }
renderPaymentQrCode(options)
Section titled “renderPaymentQrCode(options)”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
sendViaWallet(options)
Section titled “sendViaWallet(options)”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 }
verifyPayment(paymentId, txSignature?)
Section titled “verifyPayment(paymentId, txSignature?)”Poll the status of an existing payment.
const status = await tribe.verifyPayment(paymentId);Returns: PaymentStatus
sendViaPhantom(options) (deprecated)
Section titled “sendViaPhantom(options) (deprecated)”Use sendViaWallet() instead.
Subscriptions
Section titled “Subscriptions”getSubscriptions()
Section titled “getSubscriptions()”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 }] }
getActiveSubscriptions()
Section titled “getActiveSubscriptions()”Fetch the current user’s active subscriptions. Requires authentication.
const subs = await tribe.getActiveSubscriptions();Returns: UserSubscription[] — { id, tier, startsAt, expiresAt, isActive }
purchaseSubscription(tierId, mint)
Section titled “purchaseSubscription(tierId, mint)”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;}AuthConfig
Section titled “AuthConfig”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;}Announcement
Section titled “Announcement”interface Announcement { id: string; title: string; message: string; type: string;}ActiveDevice
Section titled “ActiveDevice”interface ActiveDevice { id: string; browser: string; os: string; deviceType: string; lastActiveAt: string; createdAt: string; isCurrent: boolean;}ApiKey
Section titled “ApiKey”interface ApiKey { id: string; name: string; keyPrefix: string; scopes: string[]; createdAt: string;}ApiKeyResult
Section titled “ApiKeyResult”interface ApiKeyResult { id: string; key: string; // full key — only returned from createApiKey() name: string; scopes: string[];}PasskeyCredential
Section titled “PasskeyCredential”interface PasskeyCredential { id: string; deviceName: string | null; transports: string[]; createdAt: string;}LinkedCredential
Section titled “LinkedCredential”interface LinkedCredential { id: string; provider: string; // "wallet" | "google" | "github" | "discord" | "twitter" walletAddress?: string | null; // only for wallet credentials createdAt: string;}DetectedWallet
Section titled “DetectedWallet”interface DetectedWallet { id: string; // "phantom" | "backpack" | "solflare" name: string; // "Phantom" | "Backpack" | "Solflare"}PaymentOptions
Section titled “PaymentOptions”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}PaymentResult
Section titled “PaymentResult”interface PaymentResult { id: string; // payment ID for verification paymentUrl: string; // Solana Pay URL expiresAt: string; // expires after 10 minutes}PaymentStatus
Section titled “PaymentStatus”interface PaymentStatus { status: "pending" | "confirmed" | "expired"; txSignature: string | null;}PaymentConfig
Section titled “PaymentConfig”interface PaymentConfig { paymentsEnabled: boolean; p2pPaymentsEnabled: boolean; p2pFeeRate: number; paymentWalletAddress: string | null; acceptedTokens: AcceptedToken[];}AcceptedToken
Section titled “AcceptedToken”interface AcceptedToken { mint: string; symbol: string; name: string; logoUrl: string | null; decimals: number;}RenderQrCodeOptions
Section titled “RenderQrCodeOptions”interface RenderQrCodeOptions extends PaymentOptions { container: HTMLElement; width?: number; // default 300 height?: number; // default 300}SubscriptionTier
Section titled “SubscriptionTier”interface SubscriptionTier { id: string; name: string; prices: SubscriptionTierPrice[]; intervalDays: number;}SubscriptionTierPrice
Section titled “SubscriptionTierPrice”interface SubscriptionTierPrice { mint: string; amount: string;}UserSubscription
Section titled “UserSubscription”interface UserSubscription { id: string; tier: SubscriptionTier; startsAt: string; expiresAt: string; isActive: boolean;}RedirectOptions
Section titled “RedirectOptions”interface RedirectOptions { redirectUrl?: string;}FeedbackOptions
Section titled “FeedbackOptions”interface FeedbackOptions { type?: string; email?: string;}ForgotPasswordOptions
Section titled “ForgotPasswordOptions”interface ForgotPasswordOptions { resetPasswordUrl?: string;}ResendVerificationOptions
Section titled “ResendVerificationOptions”interface ResendVerificationOptions { verifyEmailUrl?: string;}MagicLinkOptions
Section titled “MagicLinkOptions”interface MagicLinkOptions { magicLinkUrl?: string;}SocialProvider
Section titled “SocialProvider”type SocialProvider = "google" | "github" | "discord" | "twitter";