Open
Conversation
There was a problem hiding this comment.
Pull request overview
Documentation update aligning the Optimizely React SDK docs with the v4 modular client creation model, new Provider API, updated hooks, and current SSR/Next.js integration patterns.
Changes:
- Rewrote
README.mdfor v4 APIs (factory-based client creation, new hooks, Provider prop changes, SSR/RSC guidance). - Added a comprehensive v3 → v4 migration guide (
MIGRATION.md). - Updated Next.js integration guide examples to v4 and added a Table of Contents plus a module-level client pattern.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| docs/nextjs-integration.md | Updates Next.js SSR/App Router/Pages Router examples to v4 APIs and adds module-level client alternative + TOC |
| README.md | Replaces v3-focused README with v4 usage, hooks, SSR/RSC, and integration guidance |
| MIGRATION.md | New migration guide covering breaking changes from v3 to v4 |
Comments suppressed due to low confidence (1)
docs/nextjs-integration.md:67
getDatafile()is typed to returnPromise<string | undefined>and uses optional chaining (getOptimizelyConfig()?.getDatafile()), but the rest of the guide assumes a datafile is always available for SSR. Consider making this helper either throw when the datafile can’t be obtained (so SSR fails fast) or return a non-optional type onceconfigReadyresolves, to match the documented SSR requirement.
export function getDatafile(): Promise<string | undefined> {
return configReady.then(() => pollingInstance.getOptimizelyConfig()?.getDatafile());
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| | `qualifiedSegments` | `string[]` | No | Pre-fetched ODP audience segments for the user. Use [`getQualifiedSegments`](#getqualifiedsegments) to obtain these segments server-side. | | ||
| | `skipSegments` | `boolean` | No | When `true`, skips background ODP segment fetching. Default: `false`. | | ||
|
|
||
| > **Note:** `<OptimizelyProvider>` requires user data. If user information must be fetched asynchronously, resolve the promise before rendering the Provider. |
| <head> | ||
| <script | ||
| dangerouslySetInnerHTML={{ | ||
| __html: `globalThis.__OPTIMIZELY_DATAFILE__ = ${datafile};`, |
Comment on lines
+181
to
+185
| <script | ||
| dangerouslySetInnerHTML={{ | ||
| __html: `globalThis.__OPTIMIZELY_DATAFILE__ = ${datafile};`, | ||
| }} | ||
| /> |
Comment on lines
+147
to
+148
|
|
||
| export default async function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) { |
Comment on lines
107
to
109
| export function OptimizelyClientProvider({ children, datafile }: { children: ReactNode; datafile: object }) { | ||
| const isServerSide = typeof window === 'undefined'; | ||
| const isServerSide = typeof window === 'undefined'; | ||
|
|
Comment on lines
+218
to
+221
|
|
||
| const optimizely = createInstance({ | ||
| projectConfigManager: createPollingProjectConfigManager({ | ||
| sdkKey: process.env.NEXT_PUBLIC_OPTIMIZELY_SDK_KEY || '', |
| - [useDecision to useDecide](#usedecision-to-usedecide) | ||
| - [useExperiment (removed)](#useexperiment-removed) | ||
| - [useFeature (removed)](#usefeature-removed) | ||
| - [useTrackEvent (removed)](#usetrackEvent-removed) |
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
README.md: Rewritten for v4 — modular createInstance with factory functions (createPollingProjectConfigManager, createBatchEventProcessor, etc.), new hooks (useDecide, useDecideForKeys, useDecideAll + async variants), client prop on Provider, event tracking via useOptimizelyUserContext, and SSR patterns (per-request and module-level clients)Test plan
Existing tests should pass
Issues