2024-06-14
5399
#nextjs
Ejiro Asiuwhu
30990
Jun 14, 2024 ⋅ 19 min read

How to use Auth.js for client-side authentication in Next.js

Ejiro Asiuwhu Software engineer with a drive for building highly scalable and performant web applications. Heavily interested in module federation, micro frontends, state machines, TDD, and system designs. Big on web performance and optimization, advanced component design patterns, a11y, SSR, SSG, ISR, and state management. Expert at crafting highly reusable TypeScript-heavy component libraries.

Recent posts:

Million Js Adoption Guide: Overview, Examples, And Alternatives

Million.js adoption guide: Overview, examples, and alternatives

Million.js is an open source, minimalistic JavaScript compiler designed to revolutionize and improve React performance.

Isaac Okoro
Jun 28, 2024 ⋅ 6 min read
Daisy Ui Adoption Guide: Overview, Examples, And Alternatives

daisyUI adoption guide: Overview, examples, and alternatives

daisyUI is an open source component library built on top of Tailwind CSS designed to enhance the DX for web designers and developers.

David Omotayo
Jun 27, 2024 ⋅ 14 min read
Using Chrome's Document Picture In Picture Api In React

Using Chrome’s Document Picture-in-Picture API in React

Chrome’s new Document Picture-in-Picture API builds on the PIP API to open up a wider range of possibilities for user interaction.

Peter Ekene Eze
Jun 26, 2024 ⋅ 4 min read
Vercel V0 And The Future Of Ai Powered Ui Generation

Vercel v0 and the future of AI-powered UI generation

Vercel v0 is a powerful tool for rapidly prototyping various UI elements that generates code based on plain text descriptions.

Peter Aideloje
Jun 26, 2024 ⋅ 7 min read
View all posts

13 Replies to "How to use Auth.js for client-side authentication in Next.js"

  1. Really great article 😊 I really enjoyed reading it and it makes me want to switch to Next.js. I was wondering why you called this client-side rather than severless? Is the authentication not done server side by SSR? I really apologize if I’m wrong, I’m just trying to understand the authentication flow.

  2. website: next-auth.js
    Example code : next-auth-example
    npm package : next-auth

    But it is called NextAuth.js and not next-auth.js as one could guess from all your urls.

    Am I missing something here ?

  3. Unhandled Runtime Error
    Error: React Context is unavailable in Server Components

    Call Stack
    SessionProvider

    can you please resolve this error

    1. Use the “use client” flag at the top of the file.
      That error is showing up because “SessionProvider” is using react context which is a client component and for it to work, you must mark the file as a client component with the flag above.

      You are using react 13.+.+ I believe

Leave a Reply