title: Can I check if a Auth0 user is logged in already at the level of my custom NextJS _app.js?
body: <p>Working on a NextJS app using nextjs-auth0 (to which I'm totally new) for authentication. I wrapped my _app.js with <strong>UserProvider</strong> as the docs suggest and using <strong>getInitialProps</strong> to set a global online/offline status to the entire app as so;</p>
  <pre><code>import App from &quot;next/app&quot;;
  import { UserProvider} from '@auth0/nextjs-auth0';
  
  export default function MyApp({Component, pageProps, status}) {
  
          return (
              &lt;UserProvider&gt;
                  &lt;Component {...pageProps} status={status}/&gt;
              &lt;/UserProvider&gt;
          );
  };
  
  MyApp.getInitialProps = async (appContext) =&gt; {
      const appProps = await App.getInitialProps(appContext);
      const status = await getSiteStatus();
      return {appProps, status};
  };
  
  </code></pre>
  <p>This works fine and I can pick up the status of the site, even make a global offline landing page right here if I wished. I can also pick up the auth0 session from any other page using the <strong>useUser</strong> hook.</p>
  <p><strong>But here is the catch</strong>: I would like to set a global div strip above all content, informing the user that he/she is logged in and can see the site <em>although</em> it's offline. So literally every visitor will be met by a single &quot;offline&quot; page while people logged in still have the access to the all other pages and are informed they are viewing an offline site.</p>
  <p>To me the easiest way would be to simply bake that into the app page, something in style with this;</p>
  <pre><code>export default function MyApp({Component, pageProps, status, user}) {
  
          if(status)  {
  
            return (
                &lt;UserProvider&gt;
                    &lt;Component {...pageProps} status={status}/&gt;
                &lt;/UserProvider&gt;
            );
  
          } else if (user &amp;&amp; !status) {
  
             return (
                &lt;UserProvider&gt;
                    &lt;div class=&quot;somestyle&quot;&gt;You are logged in but the site is offline!&lt;/div&gt;
                    &lt;Component {...pageProps} status={status}/&gt;
               &lt;/UserProvider&gt;
  
          } else {
  
             return (
                &lt;SiteOffline /&gt;
             )
          
  };
  </code></pre>
  <p><strong>The big question</strong>: How do I get the Auth0 user session in this scenario and pass it as <em>user</em> in this case? I can not use the <strong>useUser</strong> hook since _app.js is in itself not wrapped in <strong>UserProvider</strong> and thus throws an error I can not use hooks here.</p>
  <p>I guess best would be to somehow get the auth session with <strong>getInitialProps</strong> but how without hooks? Can't seem to find any scenario like this mentioned anywhere and using an additional wrapper component sitting between this and any other component seems hugely awkward. Any ideas?</p>