Files
better-auth/demo/nextjs/app/device/layout.tsx
2025-08-21 14:59:31 -07:00

18 lines
388 B
TypeScript

import { auth } from "@/lib/auth";
import { headers } from "next/headers";
import { redirect } from "next/navigation";
export default async function DevicePage({
children,
}: {
children: React.ReactNode;
}) {
const session = await auth.api.getSession({
headers: await headers(),
});
if (session === null) {
throw redirect("/sign-in?callbackUrl=/device");
}
return children;
}