Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

508 B
Raw Blame
import { useMutation } from '@tanstack/react-query';
import { forgetOnboardingKeys } from '@/hooks/use-client-secret';
import { useTRPC } from '@/integrations/trpc/react';

export function useLogout() {
  const trpc = useTRPC();
  const signOut = useMutation(
    trpc.auth.signOut.mutationOptions({
      onSuccess() {
        // The one-time secrets must not outlive the session that minted them.
        forgetOnboardingKeys();
        window.location.href = '/';
      },
    })
  );
  return signOut;
}