Skip to main content

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:
  1. Server-side: verify users or fetch profiles directly from your backend
  2. Client-side: use a framework hook with built-in state and caching

Server-Side

The timeback.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

Use timeback.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.
This checks whether an email resolves to a Timeback account. It does not authenticate the caller or prove ownership of that email. Use an email from your authenticated session when gating access. Missing accounts return 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

Use timeback.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.
Throws a 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 browser timeback.user.fetch() method for you.

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’s refresh() 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