Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This pull request improves the documentation and implementation of server-side rendering (SSR) and ODP segment handling in the Optimizely React SDK V3.
It clarifies SSR usage in the README, adds a comprehensive Next.js integration guide, and updates the SDK's hooks to support more accurate decision-making during partial readiness states (such as when ODP segments are still being fetched). It also enhances test coverage for these scenarios.
Documentation improvements:
README.mdto explain the need for a pre-fetched datafile, updated setup instructions, and added a summary of SSR limitations. References to Next.js and React Server Components were added, and the SSR example was simplified.docs/nextjs-ssr.mdguide detailing integration patterns for both Next.js App Router and Pages Router, including code examples, feature flag usage, server component usage, and SSR limitations.SDK logic and behavior changes:
useExperiment,useFeature, anduseDecisionhooks to support synchronous decisions whengetOptimizelyConfigandgetUserContextare available, even if the client is not fully ready (e.g., ODP segments are still loading). This enables partial decisions during SSR or while waiting for async user/segment data. [1] [2] [3]Testing improvements:
Experiment.spec.tsx,Feature.spec.tsx, andhooks.spec.tsxto includegetOptimizelyConfigandgetUserContextmethods, simulating partial readiness and ODP scenarios. [1] [2] [3]Minor documentation and formatting fixes:
README.mdfor clarity and consistency. [1] [2] [3] [4] [5]These changes make SSR and ODP segment handling more robust and developer-friendly, especially for teams using Next.js or requiring partial readiness support.
Test plan
Issues