forked from nextauthjs/react-query
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
27 lines (25 loc) · 1.09 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { Session } from "next-auth"
import { UseQueryOptions } from "react-query"
/**
* Fetches session from `/api/auth/session`,
* parses its JSON response, and returns it.
* If there is no session, it returns `null`
*/
export function fetchSession(): Promise<Session | null>
/**
* React Query wrapper to retrieve `Session`.
* Replaces `useSession` and `Provider` from `next-auth/client` in codebases
* where you already use `react-query`.
*
* [`useSession`](https://next-auth.js.org/getting-started/client#usesession) |
* [`Provider`](https://next-auth.js.org/getting-started/client#provider) |
* [React Query](https://react-query.tanstack.com/guides/ssr#using-nextjs)
*/
export function useSession<R extends boolean = false>(params?: {
/** If set to `true`, the returned session is guaranteed to not be `null` */
required?: R
/** If `required: true`, the user will be redirected to this URL, if they don't have a session */
redirectTo?: string
/** Configuration for `useQuery` */
queryConfig?: UseQueryOptions<Session | null>
}): [R extends true ? Session : Session | null, boolean]