Redirects the user to the sign-in flow.
App Router only. Intended for use in Server Components, Route Handlers, and Server Actions.
This helper performs a server-side redirect to the configured sign-in route. Execution does not continue after the redirect is triggered.
| Parameter | Type | Description |
|---|---|---|
options? | RedirectToSignInOptions | Optional configuration for the redirect, such as returnUrl or additional sign-in parameters. |
Promise<void>
Never resolves. Triggers a redirect to the sign-in flow.
import { isUserInGroup, redirectToSignIn } from "@monocloud/auth-nextjs";
export default async function Home() {
const allowed = await isUserInGroup(["admin"]);
if (!allowed) {
await redirectToSignIn({ returnUrl: "/home" });
}
return <>You are signed in.</>;
}