ProtectedRoute
Renders children only when authenticated. Shows fallback otherwise.
import { ProtectedRoute } from "@allem-sdk/auth";Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children* | ReactNode | — | Content to show when authenticated |
| fallback* | ReactNode | — | Content to show when not authenticated |
| loadingFallback | ReactNode | — | Content to show while loading |
Usage
<ProtectedRoute
fallback={<LoginPage />}
loadingFallback={<Spinner />}
>
<Dashboard />
</ProtectedRoute>Tip
ProtectedRoute is a convenience wrapper. For more control over auth state, use useAuth() directly in your components.