NextAuth: How to protect route groups without middleware?
Because I'm not using SSR, I don't have access to middlewares.
My first idea was moving
useSession({required: true}) up, from my pages to my layout.
But that's not working out because useSession() only works within <SessionProvider> {children} </SessionProvider>.
Does that mean I need to create another wrapper between <SessionProvider> and my pages?
Like:
And run useSession({required: true}) inside AuthChecker ? Or is there a better way?3 Replies
Client API | NextAuth.js
The NextAuth.js client library makes it easy to interact with sessions from React applications.
you can create something like this
Thanks Fatwa, will look into it.