react
Client-side methods for NextAuth.js.
SessionProvider()β
Provider to wrap the app in to make session data available globally.
Can also be used to throttle the number of requests to the endpoint
/api/auth/session
.
SessionProvider(
props
:SessionProviderProps
):Element
Parametersβ
Parameter | Type |
---|---|
props | SessionProviderProps |
Returnsβ
Element
signIn()β
Initiate a signin flow or send the user to the signin page listing all possible providers. Handles CSRF protection.
signIn<P>(
provider
?:LiteralUnion
<P
extendsRedirectableProviderType
?BuiltInProviderType
|P
:BuiltInProviderType
,string
>,options
?:SignInOptions
,authorizationParams
?:SignInAuthorizationParams
):Promise
<P
extendsRedirectableProviderType
?SignInResponse
|undefined
:undefined
>
Type parametersβ
P
extendsundefined
|RedirectableProviderType
=undefined
Parametersβ
Parameter | Type |
---|---|
provider? | LiteralUnion <P extends RedirectableProviderType ? BuiltInProviderType | P : BuiltInProviderType , string > |
options? | SignInOptions |
authorizationParams? | SignInAuthorizationParams |
Returnsβ
Promise
<P
extends RedirectableProviderType
? SignInResponse
| undefined
: undefined
>
signOut()β
Initiate a signout, by destroying the current session. Handles CSRF protection.
signOut<R>(
options
?:SignOutParams
<R
>):Promise
<R
extends true ?undefined
:SignOutResponse
>
Type parametersβ
R
extendsboolean
= true
Parametersβ
Parameter | Type |
---|---|
options? | SignOutParams <R > |
Returnsβ
Promise
<R
extends true ? undefined
: SignOutResponse
>
useSession()β
React Hook that gives you access to the logged in user's session data.
useSession<R>(
options
?:UseSessionOptions
<R
>):SessionContextValue
<R
>
Type parametersβ
R
extendsboolean
Parametersβ
Parameter | Type |
---|---|
options? | UseSessionOptions <R > |
Returnsβ
SessionContextValue
<R
>
LiteralUnionβ
LiteralUnion: <
T
,U
>T
|U
&Record
<never
,never
>
Util type that matches some strings literally, but allows any other string as well.
Sourceβ
https://github.com/microsoft/TypeScript/issues/29729#issuecomment-832522611
Type parametersβ
T
extendsU
U
=string
SignInAuthorizationParamsβ
SignInAuthorizationParams:
string
|string
[][] |Record
<string
,string
> |URLSearchParams
Match inputType
of new URLSearchParams(inputType)