aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/app/logout/page.tsx
blob: 91ad684d8de77a2f91727aee839ae713bbbdb14f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"use client";

import { useEffect } from "react";
import { useRouter } from "next/navigation";
import { signOut } from "next-auth/react";

import { useSearchHistory } from "@karakeep/shared-react/hooks/search-history";

export default function Logout() {
  const router = useRouter();
  const { clearHistory } = useSearchHistory({
    getItem: (k: string) => localStorage.getItem(k),
    setItem: (k: string, v: string) => localStorage.setItem(k, v),
    removeItem: (k: string) => localStorage.removeItem(k),
  });
  useEffect(() => {
    signOut({
      redirect: false,
      callbackUrl: "/",
    }).then((d) => {
      clearHistory();
      router.push(d.url);
    });
  }, []);
  return <span />;
}