Is there any NextJs+apollo client example? I would...
# support-questions-legacy
a
Is there any NextJs+apollo client example? I would like to know how to handle apollo client on SSR
r
hey @ahmadbakhshi there isn't an exmaple or that specific use case. But have you seen the nextjs docs we have, specifically the part about session verification in getServerSideprops?
a
Thank you. I have now.
Just to verify I understand it correctly, if the token is still valid. then everything is fine. but if we need to refresh token, returning { fromSupertokens: 'needs-refresh' } would call the api/auth/refresh_tokem and set the new access token and relaod the page and apollo should have the correct token. Am I anything close to being correct?
r
correct!!
a
it means if the token is expired we will have 2 renders per page?
r
yes.
well, the first render would fail cause the token has expired
a
I haven't try this yet, just wondering if this render happen on server or we see a flicker as user?
r
the user wou;dnt see a flicker cause you aren't rendering anything for them in the first one - just a blank screen
a
Thank you 👍
I am working on a NestJs server. should I setup My NextJs application with backend config?
r
you don't need to in that case
a
for SSR, I need to initialize supertoken with backend config : supertokensNode.init(backendConfig())
How could I do that then?
r
yea. For SSR, you would need to do supertokensNode.init
just call that function in the getServerSideProps function
a
with no argument?
r
but all the other backend setup - adding the supertokens middleware etc, wouild happen in the nestjs backend
> with no argument? Initialise the session recipe and provide the correct appInfo object
2 Views