How to use Next-Auth with Remember Me functionality
Unanswered
Californian posted this in #help-forum
CalifornianOP
Is it possible to pass in remember me boolean to sign in [next-auth].ts file, and use it to set MaxAge of the JWT token?
11 Replies
For passing extra data:
https://next-auth.js.org/getting-started/client#additional-parameters
https://next-auth.js.org/getting-started/client#additional-parameters
Additionally it would be better to read these conversations: https://github.com/nextauthjs/next-auth/discussions/3794#discussioncomment-2628463
@Clown For passing extra data:
https://next-auth.js.org/getting-started/client#additional-parameters
CalifornianOP
Yeah I have read this a few times but they are hitting [next-auth].ts like a traditional api with fetch and passing info into the body. Right now I am using the signIn function provided by next-auth and this does not have a req with body to use
Did you check the comment above?
@Clown For passing extra data:
https://next-auth.js.org/getting-started/client#additional-parameters
CalifornianOP
Also the issue is, the credentials data is on a different scope to the session/jwt being created :
export interface AuthOptions {
providers: Provider[]
secret?: string
session?: Partial<SessionOptions>
jwt?: Partial<JWTOptions>
@Clown Did you check the comment above?
The comments above give another way of choosing the maxage
Did you check those?
@Clown The comments above give another way of choosing the maxage
CalifornianOP
So youre saying the only way is to turn the sign in into a traditional fetch call?
I dont have as much experience in next-auth but honestly, I don't think there is another way. You'll have to make a fetch call to retrieve and/or set cookies and set the max age using those
Also "Traditional Fetch call" is literally what is happening in the background anyways
@Clown I dont have as much experience in next-auth but honestly, I don't think there is another way. You'll have to make a fetch call to retrieve and/or set cookies and set the max age using those
CalifornianOP
Yeah I guess I didn't want change into a fetch call because from the looks of it you have to add so much more code, that the sign in abstracts