feat: adding isomorphic provider to bridge client and server#1218
feat: adding isomorphic provider to bridge client and server#1218
Conversation
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/browser size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/js-client-sdk-common size report |
packages/sdk/react/examples/server-only/app/BootstrapClient.tsx
Outdated
Show resolved
Hide resolved
| * We provided the optional bootstrap data that will be applied to the client-side SDK. | ||
| * Learn more about bootstrap data in the [LaunchDarkly documentation](https://launchdarkly.com/docs/sdk/features/bootstrapping). | ||
| * | ||
| * **NOTE:** The client will also ad-hoc evaluate the flags on the server-side from bootstrap data. |
There was a problem hiding this comment.
In general, I think this example name should be changed to something like react-server-example. Might want to do this in a separate change since that could add a lot of distracting changes.
247bed3 to
4613301
Compare
|
@cursor review |
8ae5305 to
2027d95
Compare
| * When provided, the client immediately uses these values before the first network | ||
| * response arrives — eliminating the flag-fetch waterfall on page load. | ||
| */ | ||
| bootstrap: unknown; |
There was a problem hiding this comment.
The typing here is to be consistent with browser sdk
|
@cursor review |
76d2c13 to
1edb021
Compare
This commit will also: - modify the server-only example to demonstrate how to use the isomorphic provider - modify the bundling so client and server can still bundle correcly with isomorphic components - refactor the client side NOOP client to be able to execute well during SSR
153d31a to
e79ea73
Compare
SDK-1946
Note
Medium Risk
Introduces new RSC/client provider components and adjusts server bundling to depend on the client entrypoint, which could affect SSR/hydration behavior and packaging if misconfigured. Behavior change in
createNoopClientinitialization state may impact consumers relying on that signal during SSR tests.Overview
Adds an isomorphic bootstrap flow for React Server Components: new server
LDIsomorphicProviderevaluatessession.allFlagsState({ clientSideOnly: true }), serializes it viatoJSON(), and renders a new'use client'LDIsomorphicClientProviderthat uses those values as client bootstrap.LDIsomorphicClientProviderselects SSR vs browser behavior: on the server it creates a noop client (viacreateNoopClient) and wraps children withcreateLDReactProviderWithClient; in the browser it initializes the real provider viacreateLDReactProvider, merging passedoptionswithbootstrap.Updates packaging/exports to surface the new APIs (
client/index.ts,server/index.ts) and tweaks build config so the server bundle treats@launchdarkly/react-sdkas external. RefinescreateNoopClientto always reportgetInitializationState()as'initializing', adds unit tests for the new providers, and updates theserver-onlyexample/docs to demonstrate bootstrapped client + server rendering (including newLAUNCHDARKLY_CLIENT_SIDE_IDrequirement and e2e expectation changes).Written by Cursor Bugbot for commit 64013be. This will update automatically on new commits. Configure here.