MCPcopy Create free account
hub / github.com/emwalker/digraph / useSession

Function useSession

next/lib/useSession.ts:34–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32}
33
34export default function useSession() {
35 const { data: session, isLoading } = useSWR(
36 sessionApiRoute,
37 fetchJson<SessionData>,
38 {
39 fallbackData: defaultSession,
40 },
41 )
42
43 const { trigger: login } = useSWRMutation(sessionApiRoute, doLogin, {
44 // the login route already provides the updated information, no need to revalidate
45 revalidate: false,
46 })
47 const { trigger: logout } = useSWRMutation(sessionApiRoute, doLogout)
48
49 return { session, logout, login, isLoading }
50}

Callers 2

PageFunction · 0.85
PageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected