[next-auth]: `useSession` must be wrapped in a <SessionProvider /> pages folder move to inside src folder-
See original GitHub issueDescription 🐜
Moving pages folder to src. Getting error [next-auth]: useSession
must be wrapped in a <SessionProvider />.
Working fine when pages folder on root dir.

Is this a bug in your own project?
No
How to reproduce ☕️
Move pages folder to inside src folder mkdir src move pages to src dir
Screenshots / Logs 📽
PFA - Error
Environment 🖥
System: OS: macOS 11.3.1 CPU: (8) arm64 Apple M1 Memory: 128.27 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.8.0 - /opt/homebrew/bin/node Yarn: 1.22.11 - /opt/homebrew/bin/yarn npm: 7.21.0 - /opt/homebrew/bin/npm Browsers: Chrome: 95.0.4638.54 Edge: 92.0.902.67 Safari: 14.1 npmPackages: next: 12.0.1 => 12.0.1 next-auth: ^4.0.0-beta.5 => 4.0.0-beta.5 react: 17.0.2 => 17.0.2
Contributing 🙌🏽
No, I am afraid I cannot help regarding this
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
javascript - [next-auth]: `useSession` must be wrapped in a ...
This is my code with the next-auth and this throwing this error "[next-auth]: useSession must be wrapped in a SessionProvider".
Read more >usesession must be wrapped in a sessionprovider - YouTube
usesession must be wrapped in a sessionprovider | next auth error in nextjs app. Watch later. Share. Copy link.
Read more >Upgrade Guide (v4) - NextAuth.js
Version 4 makes using the SessionProvider mandatory. This means that you will have to wrap any part of your application using useSession in ......
Read more >How to use NextAuth.js for client-side authentication in Next.js
Learn how to use NextAuth.js for client-side authentication in Next.js. Users can login with a GitHub, Google, or Facebook account.
Read more >next auth client fetch error | The AI Search Engine You Control
How to solve client fetch error for next-auth authentication ... Next.js! exists on the page [next-auth]: `useSession` must be wrapped in a <SessionProvider...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In my case, the problem was related to cache. I deleted the .next folder and worked.
Then that’s the issue. Your
SessionProvider
has to come beforeLayoutWrapper
.