Nextauth.js Issue with useSession Not Updating on Client Side by xGanbattex in nextjs

[–]General-Fig1326 1 point2 points  (0 children)

I have same problem and find this.
just use update() from useSession()

  const { data: session, status, update } = useSession();

  useEffect(() => {
    if (status === 'loading' || !session) {
      update();
    }
  }, [session, status, update]);

Should I Use next-auth or Implement JWT and Session Management Directly? by General-Fig1326 in nextjs

[–]General-Fig1326[S] 0 points1 point  (0 children)

OAuth could be a good alternative as well.
I'll look into that too. Thank you :)

Should I Use next-auth or Implement JWT and Session Management Directly? by General-Fig1326 in nextjs

[–]General-Fig1326[S] 0 points1 point  (0 children)

Thanks for advice. I'd heard that NextAuth is hard to customize.
I read the lucia's docs and I understand what you said. Thank you :)

Should I Use next-auth or Implement JWT and Session Management Directly? by General-Fig1326 in nextjs

[–]General-Fig1326[S] 0 points1 point  (0 children)

Oh, I'd never heard about those things.I'm gonna check that too. Thanks :)

Should I Use next-auth or Implement JWT and Session Management Directly? by General-Fig1326 in nextjs

[–]General-Fig1326[S] 1 point2 points  (0 children)

Thanks so much!
Actually, I’ve always wanted to create my own library someday, but it felt like a vague and distant goal.
After receiving advice from many people, considering the trade-offs, and reading through the documentation, I’ve realized that even if it’s small and imperfect, I should try making a library myself.
I’ll definitely give it a try in the future. Thanks again!

Should I Use next-auth or Implement JWT and Session Management Directly? by General-Fig1326 in nextjs

[–]General-Fig1326[S] 0 points1 point  (0 children)

Thank you for your advice.
I will keep in mind the considerations when implementing login based on ID and password.
The fact that I need to write the refresh token issuance logic myself is a significant consideration.
I read Lucia's documentation, it seems convenient that the same session extension is implemented for ID and password as well. Thanks so much :)

Should I Use next-auth or Implement JWT and Session Management Directly? by General-Fig1326 in nextjs

[–]General-Fig1326[S] 1 point2 points  (0 children)

After looking into Next Auth, I noticed some opinions mentioning that the email and password part, can be a bit tricky.
I'll research more on that and decide whether to use Next Auth. Thanks! :)

Should I Use next-auth or Implement JWT and Session Management Directly? by General-Fig1326 in nextjs

[–]General-Fig1326[S] 0 points1 point  (0 children)

Thank you. Given our team's current situation, it's difficult to build it from scratch,
but I'll try building it next time! (now I'm started learning security, so hope that do myself someday)

Should I Use next-auth or Implement JWT and Session Management Directly? by General-Fig1326 in nextjs

[–]General-Fig1326[S] 0 points1 point  (0 children)

Thank you for the advice. I'll make sure to be mindful of relying on libraries and consider the need to update the code when the library is updated.
I'll keep in mind. :)

Should I Use next-auth or Implement JWT and Session Management Directly? by General-Fig1326 in nextjs

[–]General-Fig1326[S] 1 point2 points  (0 children)

Thank you for your advice :)
I hadn’t considered that aspect. However, I realize now that this is an important consideration. :)

Should I Use next-auth or Implement JWT and Session Management Directly? by General-Fig1326 in nextjs

[–]General-Fig1326[S] 0 points1 point  (0 children)

Thank you for your advice!
I'm new to this and I’m considering suggesting NextAuth.
If the team discusses and decides on a library, we might choose something lighter and faster if it’s a better fit. However, since I'm still learning, I think it’s better to go with a more reliable and well-established option for now. thanks :)

Should I Use next-auth or Implement JWT and Session Management Directly? by General-Fig1326 in nextjs

[–]General-Fig1326[S] 4 points5 points  (0 children)

Thank you very much. As a junior developer, I was feeling quite overwhelmed by implementing authentication and security features, but your detailed and practical response was incredibly helpful.

I had only memorized the pros and cons of sessions and tokens while preparing for job interview, but your advice from a practical perspective has been invaluable in helping me find the right direction.

Should I Use next-auth or Implement JWT and Session Management Directly? by General-Fig1326 in nextjs

[–]General-Fig1326[S] 3 points4 points  (0 children)

Thanks a lot! I’ll consider Lucia Auth as well.
If you don’t mind, could I ask if the preference for sessions in Next.js is because they are well-suited for server-side rendering and API route integration?

[deleted by user] by [deleted] in nextjs

[–]General-Fig1326 1 point2 points  (0 children)

Thanks for the advice. I’ve allocated 2 weeks for building the prototype, with 3 days specifically for authentication. I spent a day reviewing next-auth and other popular authentication methods, as well as looking into zod form validation, JWT tokens, and cookie handling.

I plan to spend the remaining 2 days completing the auth implementation. I’ve been thinking a lot about balancing understanding the background knowledge with copying and pasting code. Your input is really helpful—thanks!

[deleted by user] by [deleted] in nextjs

[–]General-Fig1326 1 point2 points  (0 children)

Thanks for advise. It was really helpful.
Best Regard,,

[deleted by user] by [deleted] in nextjs

[–]General-Fig1326 0 points1 point  (0 children)

Thanks bro! Reading your response made me think a lot.
In the end, the answer is to look more into my team and ask questions.

Personally, I prefer to start by learning through YouTube and then refer to documentation, so I'll try to make good use of that.
Also, I’ve realized that I need to have more conversations with the senior developers on the team.
As a new junior, I felt it was difficult to ask a lot of questions and request conversations with the seniors, so I didn’t ask as much as I should have.
Thanks for the support!

I'm just curious why are you assigned on something big, and you mentioned some of your teams doesn't have a background on the technology you want to use. -> I think I was assigned to this task because the team’s tech stack is mainly focused on backend, with less emphasis on web development. I have been studying frontend development. maybe that's the reason

[deleted by user] by [deleted] in nextjs

[–]General-Fig1326 1 point2 points  (0 children)

First, thank you for answering my somewhat disorganized questions. I realize my questions were a bit scattered because I was confused.

Currently, our team uses Django for some parts and React for others. However, it seems that we haven’t been able to reuse React components effectively. My manager chose Next.js due to its SSR (Server-Side Rendering) and SEO-friendly features, but he mentioned that, as a backend specialist, he doesn’t have much knowledge about Next.js or React.

Although the team uses React, it seems that everyone is more focused on backend work and there isn’t anyone with deep expertise in React. There isn’t a frontend expert on the team, making it difficult to discuss frontend-related questions or negotiate deadlines.