Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between iron-session and next-auth?

Why would one use iron-session instead of next-auth? Doesn't next-auth do normal username/password log-in in addition to Social (while iron-session only does the former)?

like image 457
Dimitri Borgers Avatar asked Jul 20 '26 07:07

Dimitri Borgers


1 Answers

next-auth does a lot of things like you said but it also makes you do things their way. So you have to model your database a certain way to make next-auth work but it does come with a lot of helper functions and makes you write a lot less code.

iron-session only does session management. You have to write all the auth logic with iron-session which next-auth handles for you automatically.

As far as which one is better: if you'd like complete control over your database then use iron-session because sometimes next-auth might not work and it's annoying. I faced an issue with it so ditched it but it just might work for you. iron-session gives full control but you have to write the correct code. Personally, I'm facing issues with iron-session as well with useUser hook because I have to use react-query and not swr but it's probably my issue.

like image 52
deadcoder0904 Avatar answered Jul 23 '26 09:07

deadcoder0904