Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After using
jotai-ssr
for a certain period in a large-scale Next.js App Router project that heavily utilizes Jotai Atoms, we found that only a small subset of the initially anticipated use cases were necessary, while we also encountered cases where functionality was lacking. Based on these experiences, we have revamped the features provided by the library.Changes from v0.1.*
RenderingBoundary
has been replaced withSSRProvider
RenderingBoundary
has been replaced bySSRProvider
, and a simple replacement will ensure it works as expected.performanceImpactingUseUpperStore
option ofRenderingBoundary
. Instead, in environments where this is needed, placing theSSRProvider
at the appropriate location and adhering to hydration rules will achieve the same result. These rules are detailed in the new README under the section "Soft Navigation in SSR Frameworks."RenderingBoundary
was designed to automatically support soft navigation by placing it at every rendering boundary. However, based on our practical experience, its use cases turned out to be very limited. Instead, placing theProvider
manually at the appropriate locations and following hydration rules avoids opaque behavior and improves performance for commonly used scenarios.SSRProvider
is a simpleProvider
that encapsulates considerations for creating stores in SSR environments.Removal of
SuspenseBoundary
SuspenseBoundary
has been removed. It is unnecessary if hydration rules are followed.SuspenseBoundary
was redundant if the hydration rules described in the new README under "Important Notes on Hydration Logic" were followed.Addition of
useHydrateAtoms
HydrationBoundary
was the only hydration method provided byjotai-ssr
, we have addeduseHydrateAtoms
, which allows the same functionality to be utilized via a hook.While
HydrationBoundary
was particularly convenient for use in React Server Components, there were cases where a hook was more manageable. To address this, we introduceduseHydrateAtoms
.Support for Re-Hydration
HydrationBoundary
anduseHydrateAtoms
. These options make it easier to synchronize Atoms with server-side state when refreshing a page using features like Next.js'srevalidatePath
or during soft navigation in slug-based pages in frameworks like Remix or Waku. Details are provided in the README under the "Re-Hydration" section.Enhanced README
close #8