Skip to content

Junaed/fssdk 12455 doc update#331

Open
junaed-optimizely wants to merge 7 commits intomasterfrom
junaed/fssdk-12455-doc-update
Open

Junaed/fssdk 12455 doc update#331
junaed-optimizely wants to merge 7 commits intomasterfrom
junaed/fssdk-12455-doc-update

Conversation

@junaed-optimizely
Copy link
Copy Markdown
Collaborator

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)
  • MIGRATION.md: New comprehensive v3 → v4 migration guide covering all breaking changes — architecture, client creation, Provider props, hook renames/removals, removed components/HOCs, TypeScript type changes, and SSR updates
  • docs/nextjs-integration.md: Updated all examples to v4 APIs, added module-level client alternative using globalThis bridging for both App Router and Pages Router, added table of contents

Test plan

Existing tests should pass

Issues

  • FSSDK-12455

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md for 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 return Promise<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 once configReady resolves, 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.

Comment thread README.md
| `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 || '',
Comment thread MIGRATION.md
- [useDecision to useDecide](#usedecision-to-usedecide)
- [useExperiment (removed)](#useexperiment-removed)
- [useFeature (removed)](#usefeature-removed)
- [useTrackEvent (removed)](#usetrackEvent-removed)
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.

2 participants