client
SignInOptions<Redirect>
Extends
Record
<string
,unknown
>
Type parameters
Type parameter | Value |
---|---|
Redirect extends boolean | true |
Properties
callbackUrl?
optional callbackUrl: string;
Deprecated
Use redirectTo
instead.
redirect?
optional redirect: Redirect;
You might want to deal with the signin response on the same page, instead of redirecting to another page. For example, if an error occurs (like wrong credentials given by the user), you might want to show an inline error message on the input field.
For this purpose, you can set this to option redirect: false
.
redirectTo?
optional redirectTo: string;
Specify where the user should be redirected to after a successful signin.
By default, it is the page the sign-in was initiated from.
SignInResponse
Properties
code
code: undefined | string;
error
error: undefined | string;
ok
ok: boolean;
status
status: number;
url
url: null | string;
SignOutParams<Redirect>
Type parameters
Type parameter | Value |
---|---|
Redirect extends boolean | true |
Properties
callbackUrl?
optional callbackUrl: string;
Deprecated
Use redirectTo
instead.
redirect?
optional redirect: Redirect;
[Documentation](https://next-auth.js.org/getting-started/client#using-the-redirect-false-option-1
redirectTo?
optional redirectTo: string;
If you pass redirect: false
, the page will not reload.
The session will be deleted, and useSession
is notified, so any indication about the user will be shown as logged out automatically.
It can give a very nice experience for the user.
SignOutResponse
Properties
url
url: string;
SignInAuthorizationParams
type SignInAuthorizationParams: string | string[][] | Record<string, string> | URLSearchParams;
Match inputType
of new URLSearchParams(inputType)
signIn()
signIn(provider, options, authorizationParams)
signIn(
provider?,
options?,
authorizationParams?): Promise<void>
Initiates a signin flow or sends the user to the signin page listing all possible providers. Handles CSRF protection.
Parameters
Parameter | Type |
---|---|
provider ? | ProviderId |
options ? | SignInOptions <true > |
authorizationParams ? | SignInAuthorizationParams |
Returns
Promise
<void
>
Note
This method can only be used from Client Components (“use client” or Pages Router).
For Server Actions, use the signIn
method imported from the auth
config.
signIn(provider, options, authorizationParams)
signIn(
provider?,
options?,
authorizationParams?): Promise<SignInResponse>
Parameters
Parameter | Type |
---|---|
provider ? | ProviderId |
options ? | SignInOptions <false > |
authorizationParams ? | SignInAuthorizationParams |
Returns
signOut()
signOut(options)
signOut(options?): Promise<void>
Initiate a signout, by destroying the current session. Handles CSRF protection.
Parameters
Parameter | Type |
---|---|
options ? | SignOutParams <true > |
Returns
Promise
<void
>
Note
This method can only be used from Client Components (“use client” or Pages Router).
For Server Actions, use the signOut
method imported from the auth
config.
signOut(options)
signOut(options?): Promise<SignOutResponse>
Parameters
Parameter | Type |
---|---|
options ? | SignOutParams <false > |