You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was under the assumption that getInitialProps runs once on the initial page load, but it seems to run every single time I change the route?
If this is the case, how do I do the following situation (psuedo code):
App.getInitialProps = () => {
const appProps = await App.getInitialProps();
if (isServer) {
// do some stuff
return { jwt, ...appProps }
}
return { ...appProps }
}
So when the user loads the page, it has the JWT in the ReactContext available for use, but as soon as they change routes, the JWT goes missing. How can I persist this JWT between route changes once its fetched once? If the user transitions on the client side, it should continue to hold the jwt in memory.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I was under the assumption that
getInitialProps
runs once on the initial page load, but it seems to run every single time I change the route?If this is the case, how do I do the following situation (psuedo code):
So when the user loads the page, it has the JWT in the ReactContext available for use, but as soon as they change routes, the JWT goes missing. How can I persist this JWT between route changes once its fetched once? If the user transitions on the client side, it should continue to hold the jwt in memory.
Any help would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions