Skip to content

frontend


Function: default()

default(children): string | number | bigint | boolean | Iterable\<ReactNode, any, any> | Promise\<AwaitedReactNode> | Element | null | undefined

Defined in: src/auth/RequireAuth.tsx:33

RequireAuth

Route protection component that ensures user is authenticated before rendering child routes. Shows loading spinner during auth check and redirects to /login if user is not authenticated.

Preserves the intended destination in location state so users can be redirected back after successful login.

Parameters

children

Protected route components to render when authenticated

children

ReactNode

Returns

string | number | bigint | boolean | Iterable\<ReactNode, any, any> | Promise\<AwaitedReactNode> | Element | null | undefined

Example

<Route path="/dashboard" element={
  <RequireAuth>
    <Dashboard />
  </RequireAuth>
} />