Optionaloptions: RedirectToSignInOptionsOptional configuration for the redirect, such as returnUrl or additional sign-in parameters.
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.</>;
}
"use server";
import { getSession, redirectToSignIn } from "@monocloud/auth-nextjs";
export async function protectedAction() {
const session = await getSession();
if (!session) {
await redirectToSignIn();
}
return { data: "Sensitive Data" };
}
import { getSession, redirectToSignIn } from "@monocloud/auth-nextjs";
import { NextResponse } from "next/server";
export const GET = async () => {
const session = await getSession();
if (!session) {
await redirectToSignIn({
returnUrl: "/dashboard",
});
}
return NextResponse.json({ data: "Protected content" });
};
Redirects the user to the sign-in flow.
This helper performs a server-side redirect to the configured sign-in route. Execution does not continue after the redirect is triggered.