Amir
TTCTheo's Typesafe Cult
•Created by Amir on 8/27/2023 in #questions
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?4 replies