Next.js redirection/validation

Viewed 585

I'm doing a simple Next.js app, I'm a novice and I'm logging in users with a third party API which returns a JWT, I'm trying to validate each page so that if the JWT is expired, the user is redirected to the login, how can I achieve this? Currently I'm using useEffect because the router can only be used in the client-side but that loads the page and then validates the JWT, What else can I do in Next.js?

PD: I don't know much about middleware nor API routes inside next.js

1 Answers
Related