-
Hi @dai-shi and the other maintainers. First off thanks for the awesome work on this library. So I thought about using jotai in providerless mode to automatically cache api requests on the server. However since useAtom can't run on server components, I made my component a client component, let jotai cache the response on pre-render and then on a page refresh get the data from the atom. At first it seems to work great as the page loads quite fast when the pre-rendered page is painted, but then on hydration local jotai store is empty, the content disappears and gets fetched again on the client side, which I would be fine with if the original paint didn't disappear. Looking in the docs apparently one could use Correct my if I'm wrong but it seems this can't be done with the current implementation. I don't know enough about NextJs or jotai internals to know if this is doable, but is this something that would be doable. Or is a very poor idea, other than having to carefully manage memory (esp. when using atomFamily) are there any considerations against doing that, or is it not technically feasible at all. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
First of all, Yes, What you suggest is a dream solution, and it would require a tight integration with the server. |
Beta Was this translation helpful? Give feedback.
First of all,
Provider
is mandatory for server based apps. Providerless mode is only for pure SPA.Yes,
useHydrateAtoms
is the one and you need server components.What you suggest is a dream solution, and it would require a tight integration with the server.