title: How to securely store JWT tokens in react/next.js application?
body: <p>I need to store JWT token which is generated when a valid user login after proper registration through REST API. I read and find these ways to store JWT in client site: local storage, session storage, cookies, HttpOnly cookie, Browser memory (React state).</p>
  <p>Need suggestion to store JWT in the proper method and also can access some certain APIs for get with JWT token as post request header parameter user-related data.</p>
  <p>here is my login code part where I store JWT token to window object at this point, saved previously on local storage but now need to store safely in other ways except local storage or cookies.</p>
  <pre><code>const handleSubmitLogin = evt =&gt; {
  evt.preventDefault();
  var cart = new Cart();
  
  var request = new NFRequest();
  var response = request.api(HTTP_METHOD.POST, '/auth', {
      'email_address': allValuesLogin.email_login,
      'password': allValuesLogin.password_login,
      'cart_list': cart.getCartPostData(),
  });
  response.then((res) =&gt; {
      if (res.type === 'success') {
          window.$token = res.data.token
          setLoginSuccess('Successfully Login')
          setTimeout(()=&gt; {
              setLoginSuccess('');
          }, 3000)
          cart.handle({ action_type: &quot;RESET_ITEMS&quot; });
          Router.push('/account')
      } else {
          setLoginError('Wrong Email or Password')
          setTimeout(()=&gt; {
              setLoginError('');
          }, 3000);
      }
  });
  }
  </code></pre>
  <p>here I store the JWT token:<code>window.$token = res.data.token</code></p>
  <p>Thank you.</p>