Files
learn-languages/src/app/profile/LogoutButton.tsx

20 lines
612 B
TypeScript

"use client";
import LightButton from "@/components/buttons/LightButton";
import { authClient } from "@/lib/auth-client";
import { useTranslations } from "next-intl";
import { useRouter } from "next/navigation";
export default function LogoutButton() {
const t = useTranslations("profile");
const router = useRouter();
return <LightButton onClick={async () => {
authClient.signOut({
fetchOptions: {
onSuccess: () => {
router.push("/login?redirect=/profile");
}
}
});
}}> {t("logout")}</LightButton >;
}