Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.discovr.media/llms.txt

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

After signing in with a refresh token, you’ll select a profile before calling the API. Each profile gets its own recommendation state.

After sign-in: Select a profile

The SDK stores your identity credential securely. When you call API methods, it automatically handles creating and refreshing a session. You just need to select a profile first.
Think of it like a two-step handshake: identity gets you in the door; profile selection starts your browsing session.

Profiles: Separate recommendations per user

Profiles let users on the same device have separate recommendations. Each profile has its own recommendation history, watchlist, liked items, and playback state. After sign-in, list profiles with getProfiles() and select one with selectProfile() before calling the API. For a dedicated walkthrough—who’s watching UX, avatar pickers, and CRUD—see Profiles.

List and select a profile

const { profiles } = await client.getProfiles();
// profiles = [{ id: "prof_123", name: "Alice" }, ...]

await client.selectProfile(profiles[0].id);
// Session active — ready to call API

const page = await client.createPage();

Switch profiles

Calling selectProfile() again with a different id (or using switchProfile() where available) switches profiles and creates a new session, which also loads fresh recommendations for that profile.
await client.selectProfile(profiles[0].id); // Alice
await client.selectProfile(profiles[1].id); // Bob — fresh snapshot
await client.selectProfile(profiles[0].id); // Back to Alice
Perfect for household management: each family member gets their own profile with separate recommendations.

Sign out

Call signOut() to revoke the current device’s refresh token and clear all locally stored credentials. Other devices the user is signed into are not affected.
await client.signOut();
// Refresh token revoked, credentials cleared
Revocation is immediate. Any in-flight API requests complete normally, then the SDK signs out. Sign-out also triggers onAuthStateChanged() / authState / authStateStream with signedIn: false.

Reactive state

The SDK exposes two observers for state changes that happen internally — sign-in completion, profile switches, and session renewal. Both fire immediately with current state on subscribe.

Auth state

Fires on every sign-in (all flows), profile switch, and sign-out. Use it to update your UI’s logged-in state and profile display.
const unsubscribe = client.onAuthStateChanged(({ signedIn, profileId }) => {
	if (signedIn) {
		console.log("Signed in, profile:", profileId);
	} else {
		console.log("Signed out — show login screen");
	}
});

// Call unsubscribe() to stop listening

Session refreshed

Fires whenever a new session is created: on the initial selectProfile(), the automatic background refresh, and after SESSION_EXPIRED recovery. Subscribe with onSessionRefreshed() (TypeScript) or sessionState / sessionStateStream (Kotlin/Swift). Each new session produces fresh recommendations — any page data your app has cached is stale. The recommended pattern is to recreate your page on every session refresh.
client.onSessionRefreshed(({ profileId, expiresAt }) => {
	// New session — existing page IDs are stale
	recreateCurrentPage();
});
expiresAt (Unix seconds) tells you exactly when the current session will auto-refresh next — useful for showing a “session active” indicator or pre-warming data before the snapshot turns over.

Advanced: Token refresh & storage

getProfiles · selectProfile · switchProfile · createPage · signOut · onAuthStateChanged · onSessionRefreshed
Next: Handle authentication errors