ForFarm/frontend/hooks/useSession.tsx

13 lines
294 B
TypeScript

"use client";
import { SessionContext } from "next-auth/react";
import { useContext } from "react";
export function useSession() {
const context = useContext(SessionContext);
if (!context) {
throw new Error("useSession must be used within a SessionProvider");
}
return context;
}