Skip to content
Discussion options

You must be logged in to vote

But something I've been wondering about is why NextAuth uses JWT tokens and why it uses it as inside a cookie? Isn't this an antipattern? What's the point of having a cookie session with a JWT token inside it?

I would second what @balazsorban44 has said.

The short answer is that a JWT allows for cheap, fast and highly scalable authentication, because you don't need to maintain a list of all active sessions server side (e.g. in a database, on a file store) and it can be convenient in loosely distributed systems, where different products reading a session are managed by different teams or where different endpoints may be handled by de-coupled code (e.g. serverless functions) and standardi…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
5 replies
@Fronix
Comment options

@balazsorban44
Comment options

@balazsorban44
Comment options

@Fronix
Comment options

@balazsorban44
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@balazsorban44
Comment options

Answer selected by balazsorban44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
question Ask how to do something or how something works
3 participants
Converted from issue

This discussion was converted from issue #2641 on September 02, 2021 15:09.