useSessionSafe - can be used outside of session provider

This commit is contained in:
Oliver Bryan
2026-01-17 21:25:17 +00:00
parent 05022d7661
commit 4de913999e

View File

@@ -21,6 +21,11 @@ export function useSession(): SessionContextValue {
return context;
}
// safe version that returns null if outside provider
export function useSessionSafe(): SessionContextValue | null {
return useContext(SessionContext);
}
// for use inside RequireAuth
export function useAuthenticatedSession(): { user: UserRecord; setUser: (user: UserRecord) => void } {
const { user, setUser } = useSession();