ScuteClient is the object every call goes through. createClient(config) and new ScuteClient(config) are the same.
import { createClient } from "@scute/js-core";const scute = createClient({ appId: process.env.SCUTE_APP_ID });Options#
Preferences#
What the client does on start#
The constructor fetches the app's settings (getAppData()), which decide the sign-in method, whether passkeys are on, and auto refresh. In a browser it also opens a BroadcastChannel for cross-tab sync, starts the background refresh and listens for tab visibility.
A failed settings load is not cached: the next call tries again. signIn and signInOrUp return that error instead of guessing a method.
const { data: app, error } = await scute.getAppData();// app.email_auth_type: "magic" | "otp"// app.passkeys_enabled, app.allowed_identifiers, app.oauth_providers, ...const fresh = await scute.getAppData(true); // skip the cached copyStorage#
Every key the client writes is suffixed with __ and the app ID, so two Scute apps on one origin keep separate sessions.
| Key | Holds |
|---|---|
| sc-access-token__<appId> | The access token |
| sc-refresh-token__<appId> | The refresh token |
| sct_last_login__<appId> | The last identifier used to sign in |
| sct_cred_data__<appId> | Passkey credential IDs registered on this device |
A storage adapter is any object with getItem(key), setItem(key, value) and removeItem(key), sync or async. For cookies, extend ScuteCookieStorage, or use ScuteBrowserCookieStorage (cookies set with js-cookie):
import { createClient, ScuteBrowserCookieStorage } from "@scute/js-core";const scute = createClient({ appId: "YOUR_APP_ID", preferences: { sessionStorageAdapter: new ScuteBrowserCookieStorage({ sameSite: "lax" }), },});Cookies are Secure by default, except on plain http://localhost pages. The default path is /.
Sandbox#
scute.isSandbox is true once a response carried X-Scute-Sandbox: true. scute.environment is "production" or "sandbox".
One client per app#
Create the client once and share it. A second ScuteClient for the same app ID in one browser logs a warning; clients for different app IDs coexist.
The client also holds:
| Property | Type | Page |
|---|---|---|
| scute.admin | ScuteAdminApi | Admin API |
| scute.authz | ScuteAuthzApi | Permission checks |
| scute.verifications | ScuteVerifyApi | Verifications inbox |
| scute.appId, scute.baseUrl | string |