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 |
153d31a to
e79ea73
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
64013be to
71795a3
Compare
fc278c0 to
0f76c59
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

SDK-1946
Note
Medium Risk
Adds new server/client bridge components and changes SSR/noop-client initialization semantics, which can affect hydration and initial flag state in React Server Components apps. Also adjusts build configuration to avoid bundling issues between server and client entrypoints.
Overview
Introduces an isomorphic provider path for React Server Components:
LDIsomorphicProvider(server component) computes bootstrap data viasession.allFlagsState({ clientSideOnly: true }).toJSON()and renders a new'use client'LDIsomorphicClientProviderthat initializes the browser SDK with that bootstrap.Updates the SSR
createNoopClientstub to always reportgetInitializationState()as'initializing'(while still treating presence of bootstrap asisReady()), and adds coverage for the new providers plus updated noop-client expectations.Refreshes the
server-onlyexample and migration docs to demonstrate server-evaluated flag bootstrap (adds requiredLAUNCHDARKLY_CLIENT_SIDE_ID, a client component usinguseBoolVariation, and updated e2e assertion), and tweaks packaging (tsup/tsconfigpath mapping + server bundleexternal) so the server entry can reference the client package without bundling conflicts.Written by Cursor Bugbot for commit 9fa80fd. This will update automatically on new commits. Configure here.