"use client"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { useAppForm } from "@/components/ui/tanstack-form"; import { cn } from "@/lib/utils"; import { getSession, signIn } from "next-auth/react"; import { useSearchParams } from "next/navigation"; import { useTransition } from "react"; import { toast } from "sonner"; import * as z from "zod"; import { InteractiveGridPattern } from "./interactive-grid"; const signInSchema = z.object({ email: z.string().email("Enter a valid email address"), password: z.string().min(8, "Password must be at least 8 characters"), }); export default function SignInViewPage() { const searchParams = useSearchParams(); const callbackUrl = searchParams.get("callbackUrl") ?? "/dashboard/crm"; const [isPending, startTransition] = useTransition(); const form = useAppForm({ defaultValues: { email: "", password: "", }, validators: { onSubmit: signInSchema, }, onSubmit: ({ value }) => { startTransition(async () => { const result = await signIn("credentials", { email: value.email, password: value.password, redirect: false, }); if (result?.error) { toast.error("Invalid email or password"); return; } await getSession(); toast.success("Signed in successfully"); window.location.assign(callbackUrl); }); }, }); return (
“Move from template scaffolding to app-owned auth and data without tearing up the dashboard UX.”
Use the credentials created for you by a super admin or organization admin.
This starter now uses app-owned authentication with Auth.js and an internal organization model.