Skip to content
rw3iss Auth

ProtectedRoute

atom @rw3iss/auth-client/preact/atoms/ProtectedRoute framework-adapters/preact/components/atoms/ProtectedRoute.tsx ↗

Render children only if the caller is authenticated. While the AuthClient is still bootstrapping, renders the loading fallback (default: an inline <AuthLoading/>-style placeholder).

Anonymous state renders the fallback — typically a redirect component from your router, or an inline “please sign in” view. The component itself does not navigate; that’s a router concern.

Usage

<ProtectedRoute fallback={}>

Usage

import { ProtectedRoute } from '@rw3iss/auth-client/preact/atoms';
<ProtectedRoute
children={<></>}
/>

Props

NameTypeDescription
childrenComponentChildren(required)
fallbackComponentChildrenRendered when the user is anonymous / offline / session expired.
loadingComponentChildrenRendered while AuthClient is still bootstrapping.
clientAuthClient