1

I am using Nextjs with axios. After login I set the auth token in http-only cookie for secure api calls. The problem is I want to check whether user is logged in by verifying whether the cookie exists. The website is designed in a way where user can land on any page(have more than 50 pages) and not necessarily homepage.

Is there a way I can check if cookie exists by creating a wrapper for whole app. I tried using getInitialProps in _app.js but no luck. Any help is appreciated.

RItesh Gupta
  • 83
  • 1
  • 6
  • Do you mean something like: [Creating a HOC (higher order component) for cookies in nextJS](https://stackoverflow.com/questions/66081052/creating-a-hoc-higher-order-component-for-cookies-in-nextjs)? – juliomalves Aug 23 '21 at 21:40

0 Answers0