NextAuthjs
Unanswered
bray posted this in #help-forum
brayOP
Im new to the use of Nextjs especially implementing Access Token and Refresh Token. Anyone knows why NextAuth is cutting Access Token characters returned from the backend instead of just storing it all in the authjs.session-token ?
8 Replies
@bray Im new to the use of Nextjs especially implementing Access Token and Refresh Token. Anyone knows why NextAuth is cutting Access Token characters returned from the backend instead of just storing it all in the authjs.session-token ?
You should be aware that NextAuth is no longer evolving as a standalone project and is now maintained as part of Better Auth, which is why Better Auth is recommended for new implementations.
@Nuitari You should be aware that NextAuth is no longer evolving as a standalone project and is now maintained as part of Better Auth, which is why Better Auth is recommended for new implementations.
brayOP
Does it take a lot of code recatoring when switching between NextAuth and Better Auth?
@bray Does it take a lot of code recatoring when switching between NextAuth and Better Auth?
if you are advanced in your app i think you can keep in next auth unless you face problems
anyway if you wanna try it better create a new proyect implement it and if you find it meet your requeriments then made the switch
always test stuff isolated is always my way to go no matter if is a library or a new feature of react or nextjs
@bray Does it take a lot of code recatoring when switching between NextAuth and Better Auth?
Whooping Crane
Hey bray, I’ve seen the Access Token truncation issue with NextAuth happen me before usually due to how the session cookie is being stored, the cookie has a max size
If you’re still having trouble, I’d be glad to give it a look or help you debug it I’ve built a few auth implementations recently so may be able to spot it). Just offering, don’t feel obligated though! 👍
If you’re still having trouble, I’d be glad to give it a look or help you debug it I’ve built a few auth implementations recently so may be able to spot it). Just offering, don’t feel obligated though! 👍
Rottweiler
It’s most likely not NextAuth intentionally cutting your access token, but rather hitting the browser’s cookie size limit (around 4KB) since
authjs.session-token is stored as a cookie, so if your access token or overall session payload is too large it gets truncated, and you should verify by logging the token before storing and after retrieving it, then consider reducing its size or storing it server-side instead of directly in the session cookie.