UNPKG

@wristband/react-client-auth

Version:

A lightweight React SDK that pairs with your backend server auth to initialize and sync frontend sessions via secure session cookies.

20 lines (17 loc) 597 B
import { useContext } from 'react'; import { WristbandAuthContext } from '../context/wristband-auth-context.js'; function useWristbandSession() { const context = useContext(WristbandAuthContext); if (context === undefined) { throw new Error('useWristbandSession() must be used within a WristbandAuthProvider.'); } return { metadata: context.metadata, tenantId: context.tenantId, userId: context.userId, updateMetadata: (newMetadata) => { context.updateMetadata(newMetadata); }, }; } export { useWristbandSession };