Overview
The user profile contains an enriched view of the current user, including identity information, school, grade, enrolled courses, goals, and XP totals. You can access user data in several ways:- Server-side: verify users or fetch profiles directly from your backend
- Client-side: use a framework hook with built-in state and caching
Server-Side
Thetimeback.user namespace provides programmatic methods that accept an email directly. Use them in your own API routes, server actions, webhooks, cron jobs, or any backend context.
Verify a user
Usetimeback.user.verify(email) to check whether a Timeback user exists for a given email. This is a lightweight check — it does not fetch enrollments, analytics, or build an enriched profile.
verified: false; ambiguous matches and lookup failures reject.
boolean
Whether the user exists in Timeback.
string
The Timeback user ID. Only present when
verified is true.Get a user profile
Usetimeback.user.getProfile(email) to get the full enriched profile — identity, enrollments, courses, goals, and XP. This is the programmatic equivalent of the /user/me HTTP handler.
TimebackUserResolutionError if the user cannot be resolved. If you’re not sure whether a user exists, call verify() first.
Client-Side
On the client, use the framework-specific profile hook. The hook handles loading state, caching, and session-aware refetching — the hooks call the browsertimeback.user.fetch() method for you.
- React
- Vue
- Svelte
- Solid
Hook State
The profile hook returns a state object with these statuses:Caching
The client SDK caches profile data to minimize API calls:- Profile requests share an in-flight request and a five-second cache per client instance. Verification has a separate 1.5-second cache.
fetchProfile()can reuse the fresh cache; the hook’srefresh()bypasses it.- The reviewed shared cache has no explicit sign-out invalidation function. Hook state resets when verification becomes unverified; do not treat cached profile presence as authorization.
The profile XP totals sum the user’s returned EduBridge facts across apps, not only this integration. Courses include returned enrollments; configuration supplies a course code when matched, rather than filtering the list. Goals come from the first returned enrollment with goals.
Next Steps
Custom Activities
Track activities to earn XP
Identity
Authentication setup
EduBridge Client
Advanced analytics queries
OneRoster Client
Query enrollments directly