Skip to content

Junaed/fssdk 10777 ssr doc update#318

Open
junaed-optimizely wants to merge 4 commits into3.x.xfrom
junaed/fssdk-10777-ssr-doc-update
Open

Junaed/fssdk 10777 ssr doc update#318
junaed-optimizely wants to merge 4 commits into3.x.xfrom
junaed/fssdk-10777-ssr-doc-update

Conversation

@junaed-optimizely
Copy link
Contributor

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:

  • Expanded and clarified the SSR section in README.md to 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.
  • Added a new docs/nextjs-ssr.md guide 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:

  • Updated the useExperiment, useFeature, and useDecision hooks to support synchronous decisions when getOptimizelyConfig and getUserContext are 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:

  • Enhanced test mocks in Experiment.spec.tsx, Feature.spec.tsx, and hooks.spec.tsx to include getOptimizelyConfig and getUserContext methods, simulating partial readiness and ODP scenarios. [1] [2] [3]
  • Added and updated tests to verify that hooks and components re-render with updated decisions once ODP segment fetching completes, ensuring correct feature flag behavior during partial readiness. [1] [2] [3]

Minor documentation and formatting fixes:

  • Cleaned up code samples and formatting in README.md for 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

  • FSSDK-10777

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant