With your current structure ProjectLayout
isn’t getting wrapped by the AuthContext
, meaning you won’t have access to its context.
You can modify your _app
‘s structure and move the getLayout
call around so that the context wraps it properly.
function MyApp({ Component, pageProps }) {
const getLayout = Component.getLayout || ((page) => page);
return (
<AuthContext>
{getLayout(<Component {...pageProps} />)}
</AuthContext>
);
}