CapxulDashboardAccess
One root that decides whether a person may see a dashboard, plus the four state parts that take turns rendering.
CapxulDashboardAccess answers one question: may this person see this
dashboard? It owns the session restore wait, the membership and lifecycle
probes, redirect legality and the branch between them. It draws nothing.
Its four parts take turns. Exactly one renders per phase, so a screen that places all four is never blank by accident.
Import
import { CapxulDashboardAccess } from "@capxul/sdk-react";Usage
"use client";
import { CapxulDashboardAccess } from "@capxul/sdk-react";
function DashboardGate({ orgId, children }: { orgId?: string; children: ReactNode }) {
return (
<CapxulDashboardAccess scope={{ kind: "organization", orgId }}>
<CapxulDashboardAccess.Checking>{null}</CapxulDashboardAccess.Checking>
<CapxulDashboardAccess.Error>
{({ error, retry }) => <ErrorScreen error={error} onRetry={retry} />}
</CapxulDashboardAccess.Error>
<CapxulDashboardAccess.Redirect>
{({ destination }) => <MyRedirect destination={destination} />}
</CapxulDashboardAccess.Redirect>
<CapxulDashboardAccess.Granted>{children}</CapxulDashboardAccess.Granted>
</CapxulDashboardAccess>
);
}Props
scope: { kind: "personal" } | { kind: "organization"; orgId?: string }For an organization scope the root grants only the exact organization asked for: the person must be a member of it, and that organization's lifecycle must read ready.
The parts
| Part | Takes | Hands |
|---|---|---|
.Checking | plain children | nothing — render your skeleton, or null |
.Error | a render function | { error: CapxulError; retry(): void } |
.Redirect | a render function | { destination: IdentityDestination } |
.Granted | plain children | nothing |
.Redirect performs no navigation. It hands you the destination and your
application makes the routing move, because routing is yours.
retry() re-runs only the probe that failed, never all three.
It waits rather than guessing
Every branch fails closed. A state the component has never met — a new identity
phase, a new organization lane position — holds .Checking. It is never read
as a settled "you may not be here", so a person who is in fact signed in is
never bounced while a probe is still in flight.
Omitting a part has a cost: a screen without .Redirect strands the person on a
page they may not see, and a screen without .Error shows a permanently blank
gate after a probe fails. In development the root warns when it reaches a phase
whose part is absent.
Rules
- A part used outside
<CapxulDashboardAccess>throws. - There is no companion hook. The component is the one way in.
Related
isRestoringandisClaimed— the two identity selectors, for gates you write yourself.