title: NextJS ReferenceError: document is not defined
body: <p>I am making a NextJS app. I am using cookies to save access tokens returned from REST API.
  In <code>login.js</code>, cookies are being created successfully:</p>
  <pre><code>  document.cookie = `token=${res.data.result.accessToken}; path=/;`;
    
  </code></pre>
  <p>but when I access it in <code>header.js</code> :</p>
  <pre><code>if (document.cookie.split(';').some((item) =&gt; item.trim().startsWith('token='))) {
       SetAuth(&quot;true&quot;);
  }
  </code></pre>
  <p>it says;</p>
  <pre><code>ReferenceError: document is not defined
  </code></pre>
  <p>Any reason, or any other way to save tokens and access them?</p>