Skip to main content

Documentation Index

Fetch the complete documentation index at: https://setup.despia.com/llms.txt

Use this file to discover all available pages before exploring further.

Post sign-in routes: open the prebuilt profile sheet, sign out, sync the user ID into analytics SDKs, switch tenants.

User Profile

Clerk’s prebuilt account-management sheet. The user can edit their profile, manage emails, phones, external accounts, passkeys, sessions, MFA, and delete their account.
ParamValuesDefault
dismissabletrue, false, 1, 0, yes, notrue
despia('clerk://userprofile?dismissable=true')
Requires the user to be signed in. Emits userprofile with status: "closed" when the sheet dismisses, so you can refresh the UI for any profile edits the user just made.
window.onClerkEvent = (r) => {
    if (r.ok && r.event === 'userprofile' && r.status === 'closed') {
        // User dismissed the profile sheet, re-read state to pick up any edits
        despia('clerk://state')
    }
}
Errors emit with event: "userprofile": not_configured, unsupported_os, sdk_not_linked.

Sign Out

Revokes the current session server-side, stops the JWT refresher, clears window.clerkJWT, clears attribution IDs, and writes the signed-out cookie state.
despia('clerk://signout')
{
    "ok": true,
    "event": "signOut",
    "status": "complete"
}
Pair with your SPA router:
window.onClerkEvent = (r) => {
    if (r.ok && r.event === 'signOut') {
        navigate('/')
    }
}
navigate is your SPA router’s navigation function. Errors emit with event: "signOut": not_configured, signout_failed, unsupported_os, sdk_not_linked.

Multi-Tenant

Call clerk://configure again with a different publishable key. The bridge wipes the secure session store, signs the user out, clears attribution IDs, clears SSR cookies, and re-emits ready with status: "reconfigured".
async function switchTenant(newKey) {
    return new Promise((resolve) => {
        const prev = window.onClerkEvent

        window.onClerkEvent = (r) => {
            prev?.(r)
            if (r.event === 'ready' && r.publishableKey === newKey) {
                resolve(r)
            }
        }

        despia('clerk://configure?key=' + newKey)
    })
}
A second reconfigure while one is in flight returns reconfigure_in_progress. Wait for the first ready before issuing another.

Attribution Sync

Auto-syncs the Clerk userId into OneSignal and AppsFlyer. On by default. Every successful sign-in or sign-up pushes the userId to both SDKs, sign-out or tenant switch clears them.
ParamValuesDefault
enabledtrue, falsetrue
// Default, already on
despia('clerk://attribution')

// Disable and clear any auto-set IDs
despia('clerk://attribution?enabled=false')
{
    "ok": true,
    "event": "attribution",
    "status": "enabled"
}
OneSignal sync only fires when Push Notifications is enabled in the Despia Editor. AppsFlyer sync only fires when AppsFlyer is enabled. To key analytics on your own internal user ID instead of Clerk’s, override after sign-in. Last write wins.
// Override OneSignal user ID
despia('setonesignalplayerid://?user_id=internal_user_123')

// Override AppsFlyer customer user ID
despia('appsflyer://set_user_id?customer_user_id=internal_user_123')

Resources

NPM Package

despia-native