Switch between SSR and SSG based on authentication status
Unanswered
Pacific thread herring posted this in #help-forum
Pacific thread herringOP
I am working on an app running Next 13.x. We are still using the pages router and we use ISR to render the route in question.
I would like it so when a user is authenticated (i.e. he is an admin that can author content) any pages he visit is considered stale and a fresh copy is rendered from the server. If the user is not authenticated, the regular ISR flow should happen, so if the pages is already statically cached it gets rendered directly from there and otherwise from the server.
We are using Next Auth for authentication. The problem I'm facing, though, is that the revalidation settings all get set within
I would like it so when a user is authenticated (i.e. he is an admin that can author content) any pages he visit is considered stale and a fresh copy is rendered from the server. If the user is not authenticated, the regular ISR flow should happen, so if the pages is already statically cached it gets rendered directly from there and otherwise from the server.
We are using Next Auth for authentication. The problem I'm facing, though, is that the revalidation settings all get set within
getStaticProps() which will only run on the server. How can I know the authentication status from there?