cal.pub0.org/apps/web/lib/hooks/useToggleQuery.tsx

10 lines
203 B
TypeScript

import { useSearchParams } from "next/navigation";
export function useToggleQuery(name: string) {
const searchParams = useSearchParams();
return {
isOn: searchParams?.get(name) === "1",
};
}