Redirect to sign-in
Sends the browser to sign-in when it renders. Put it in the signed-out branch of a page that needs a session.
This component has no preview: it leaves the page as soon as it renders.
Installation
- npm
- pnpm
- Yarn
- Bun
npm install @lumoauth/react
pnpm add @lumoauth/react
yarn add @lumoauth/react
bun add @lumoauth/react
Usage
src/pages/Dashboard.tsx
import { SignedIn, SignedOut, RedirectToSignIn } from '@lumoauth/react';
export default function DashboardPage() {
return (
<>
<SignedIn>
<Dashboard />
</SignedIn>
<SignedOut>
<RedirectToSignIn />
</SignedOut>
</>
);
}
In a Next.js app, protect the route on the server instead, so that the page is never sent to a signed-out browser. See the server-side session recipe.
Props
| Prop | Type | Description |
|---|---|---|
signInUrl | string | Used only in password mode, which LumoAuth does not support. In the default mode the component starts the hosted sign-in. |