Next.js Discord

Discord Forum

Best way to get user data on server side only once?

Unanswered
Cuban Crocodile posted this in #help-forum
Open in Discord
Cuban CrocodileOP
I only need to retrieve data about the user when the user visits the page for the first time.
And then I take the server-loaded data to the user provider and store it there.
I need this so that I don't have to retrieve user data every time the page changes.
But if I use getInitialProps with (typeof window === "undefined") inside, then when I go to the page that getServerSideProps uses, getInitialProps is forced to run.
How to get rid of this?
Something like shallow routing will help me?

1 Reply