Refresh the access token
Access tokens are short-lived. Use therefresh method to obtain a new one without requiring the user to log in again. The SDK handles caching and prevents concurrent refresh calls across browser tabs automatically.
How is the refresh flow secured?
How is the refresh flow secured?
The refresh flow is protected by DPoP (Demonstration of Proof-of-Possession). The SDK generates a cryptographic key pair and signs each refresh request with a proof that binds the request to the client. This protects against:
- Token theft — A stolen refresh cookie is unusable without the private key, which is bound to the browser and never transmitted
- Token replay — Each DPoP proof includes a unique identifier and timestamp, preventing reuse
- Man-in-the-middle attacks — The proof binds to the HTTP method and URL, so it cannot be replayed against a different endpoint
- Token export — The key pair is non-extractable, meaning it cannot be copied from the browser to another device
refresh call to hit the backend (bypassing the local cache), invalidate the cache first:
Try it
Try it
In the login Each click fetches a new access token and updates the decoded token content.
App.jsx above, add decode to your import (import { ..., decode } from "@prelude.so/js-sdk") and replace the article block with:Log out
When a user logs out, calllogout to revoke the session and clear the local cache:
Try it
Try it
Add a logout button next to the refresh button in the authenticated view:The user is redirected back to the login form after logout.
List sessions
Retrieve all active sessions for the authenticated user:id, device_type, device_model, os_version, country_code, created_at, and last_seen_at.
Try it
Try it
Replace
src/App.jsx with:src/App.jsx
Revoke sessions
UserevokeSessions to revoke sessions. The target parameter controls which sessions are revoked:
| Target | Description |
|---|---|
"all" | Revoke all sessions, including the current one. |
"others" | Revoke all sessions except the current one. |
"mine" | Revoke the current session only. |
"session" | Revoke a specific session by ID. |
Try it
Try it
Building on the list sessions example above, add revocation controls. Replace
src/App.jsx with:src/App.jsx