Skip to main content

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.

ComponentReadyView source
Works with
ReactNext.js

This component has no preview: it leaves the page as soon as it renders.

Installation​

npm install @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​

PropTypeDescription
signInUrlstringUsed only in password mode, which LumoAuth does not support. In the default mode the component starts the hosted sign-in.