undefined session in _app.tsx file
I want to get the session in the app file but undefined always appears, however the hooks work and return the session
10 Replies
I'm missing something?
Show your _app
But I recommend debugging by logging the _app props
Like:
i'm trying to use
defineAbility
function, to define RBAC
but I think I’ll create a component that wraps AbilityContext.Provider
and children, as useSession
hook are workingYo
Sorry for the delay, I got really busy
I think it really isn't possible to pass down the props to the Component, but what you can and probably should do, is get it on the server side, for example:
you could do a step further and abstract that, if your getServerSideProps are repeated all the time:
and to have full type safety, I did it like this:
create a
src/types/next.d.ts
file and have this:
Then type the _app like this:
and the pages like this:
the next.d.ts is what I remember finding on my research so that the PageProps and AppProps remained consistent by just adding into the existent one from next