2025-09-21 11:02:31 -07:00
|
|
|
import Form from "next/form";
|
2026-03-13 23:18:01 +00:00
|
|
|
import { headers } from "next/headers";
|
|
|
|
|
import { redirect } from "next/navigation";
|
|
|
|
|
import { auth } from "@/lib/auth";
|
2024-10-24 16:35:51 -04:00
|
|
|
|
|
|
|
|
export const SignOutForm = () => {
|
|
|
|
|
return (
|
|
|
|
|
<Form
|
|
|
|
|
action={async () => {
|
2025-09-21 11:02:31 -07:00
|
|
|
"use server";
|
2024-10-24 16:35:51 -04:00
|
|
|
|
2026-03-13 23:18:01 +00:00
|
|
|
await auth.api.signOut({
|
|
|
|
|
headers: await headers(),
|
2024-10-24 16:35:51 -04:00
|
|
|
});
|
2026-03-13 23:18:01 +00:00
|
|
|
|
|
|
|
|
redirect("/");
|
2024-10-24 16:35:51 -04:00
|
|
|
}}
|
2025-09-21 11:02:31 -07:00
|
|
|
className="w-full"
|
2024-10-24 16:35:51 -04:00
|
|
|
>
|
|
|
|
|
<button
|
2025-09-21 12:03:29 +01:00
|
|
|
className="w-full px-1 py-0.5 text-left text-red-500"
|
2025-09-21 11:02:31 -07:00
|
|
|
type="submit"
|
2024-10-24 16:35:51 -04:00
|
|
|
>
|
|
|
|
|
Sign out
|
|
|
|
|
</button>
|
|
|
|
|
</Form>
|
|
|
|
|
);
|
|
|
|
|
};
|