useSession
Exposes the current session validation status from the StudioProvider.
Import
ts
import { useSession } from "@asset-studio/core";Usage
tsx
function SessionGuard() {
const { sessionStatus } = useSession();
if (sessionStatus === "loading") return <p>Validating session...</p>;
if (sessionStatus === "expired" || sessionStatus === "error")
return <p>Session invalid.</p>;
return <p>Session active</p>;
}Return Value
| Property | Type | Description |
|---|---|---|
sessionStatus | SessionStatus | Current session status. |
errorFallback | ReactNode | undefined | Fallback UI passed to StudioProvider via the errorFallback prop. |
Types
ts
type SessionStatus = "loading" | "valid" | "expired" | "error";Notes
- The session check is made once on mount of
StudioProvider. - While
sessionStatusis'loading', the editor will not render visible content. - On
'expired'or'error', theerrorFallbackfrom the provider is rendered if provided.