New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persisting InMemoryCache when using SSR #5475
Comments
In my app, I'm using:
I believe this approach means that SSR won't be able to access the cache but the client will access the cache rather than making network calls once the initial SSR has completed. All calls made from the client will have access to the cache. |
@ajhool, thanks for sharing your setup. Can you please show how you are initializing the apollo client? |
Have you figured you how to implement this? I am running in the same issue? |
@ajhool and @sakhmedbayev Woudl you guys be willing to help out and opensource a boilerplate? https://spectrum.chat/apollo/general/best-practice-ac3-persistent-caching-reactive-vars-and-nextjs-ssr~c1f91bc5-e390-46f9-ac70-5e3fb3b23df7 |
I know this might be a bit state... but did you come up with a solution? I'm a bit puzzled about getting this to work using reactive variables for local state management. |
@pescoboza , same here. Anyone found solution? |
Hello @RishikeshDarandale! It worked for me, but use this at your own risk. I have not tested performance or security.
|
I think I've managed to add apollo cache persist based on existing example in Next.js - vercel/next.js#29718 |
Thanks all for the great discussion! I think this question touches upon a larger question of how Apollo Client should be used in SSR contexts. This is of particular interest now that React Server Components have been adopted by Next.js. I'm doing some housekeeping and in the interest of focusing on actionable issues I'll close this one for now. Please feel free to use our community forum to share some ideas as well! If you feel strongly this should remain open please let me know, happy to accommodate 🙏🏻 |
Hi there,
What is the recommended way to persist
InMemoryCache
when using server side rendering?If my app was not server side rendered I could just persist to localStorage.
Having trouble trying to figure out how to persist
InMemoryCache
when using NextJS.The text was updated successfully, but these errors were encountered: