Skip to content
Blog

Sessions & Devices

Each time a user signs in, Tribe creates a session record that captures the browser, operating system, and device type. This makes it straightforward to build a device management page where users can see everywhere they’re logged in and revoke sessions they don’t recognize. Think of the “active sessions” panel in apps like GitHub or Google.

import { Tribe } from "@tribecloud/sdk";
const devices = await tribe.getActiveDevices();
// Returns: [{ id, browser, os, deviceType, lastActiveAt, createdAt, isCurrent }]
await tribe.revokeSession(sessionId);
await tribe.invalidateAllSessions();
// All sessions are destroyed — user is logged out on every device
function DeviceList() {
const [devices, setDevices] = useState([]);
useEffect(() => {
tribe.getActiveDevices().then(setDevices);
}, []);
const revoke = async (id) => {
await tribe.revokeSession(id);
setDevices((d) => d.filter((dev) => dev.id !== id));
};
return (
<ul>
{devices.map((d) => (
<li key={d.id}>
{d.browser} on {d.os} ({d.deviceType})
{d.isCurrent ? " (this device)" : (
<button onClick={() => revoke(d.id)}>Revoke</button>
)}
</li>
))}
</ul>
);
}