shellphone.app/app/features/core/hooks/use-session.ts
2022-05-20 00:55:02 +02:00

14 lines
379 B
TypeScript

import { useMatches } from "@remix-run/react";
import type { SessionData } from "~/utils/auth.server";
export default function useSession() {
const matches = useMatches();
const __appRoute = matches.find((match) => match.id === "routes/__app");
if (!__appRoute) {
throw new Error("useSession hook called outside _app route");
}
return __appRoute.data as SessionData;
}