Skip to content

feat: adding isomorphic provider to bridge client and server#1218

Open
joker23 wants to merge 10 commits intomainfrom
skz/sdk-2043/rsc-bootstrap
Open

feat: adding isomorphic provider to bridge client and server#1218
joker23 wants to merge 10 commits intomainfrom
skz/sdk-2043/rsc-bootstrap

Conversation

@joker23
Copy link
Copy Markdown
Contributor

@joker23 joker23 commented Mar 24, 2026

SDK-1946

  • 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

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 createNoopClient initialization state may impact consumers relying on that signal during SSR tests.

Overview
Adds an isomorphic bootstrap flow for React Server Components: new server LDIsomorphicProvider evaluates session.allFlagsState({ clientSideOnly: true }), serializes it via toJSON(), and renders a new 'use client' LDIsomorphicClientProvider that uses those values as client bootstrap.

LDIsomorphicClientProvider selects SSR vs browser behavior: on the server it creates a noop client (via createNoopClient) and wraps children with createLDReactProviderWithClient; in the browser it initializes the real provider via createLDReactProvider, merging passed options with bootstrap.

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-sdk as external. Refines createNoopClient to always report getInitializationState() as 'initializing', adds unit tests for the new providers, and updates the server-only example/docs to demonstrate bootstrapped client + server rendering (including new LAUNCHDARKLY_CLIENT_SIDE_ID requirement and e2e expectation changes).

Written by Cursor Bugbot for commit 64013be. This will update automatically on new commits. Configure here.


Open with Devin

@github-actions
Copy link
Copy Markdown
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25661 bytes
Compressed size limit: 29000
Uncompressed size: 126143 bytes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 24, 2026

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 179253 bytes
Compressed size limit: 200000
Uncompressed size: 828804 bytes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 24, 2026

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 31446 bytes
Compressed size limit: 34000
Uncompressed size: 111621 bytes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 24, 2026

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 37015 bytes
Compressed size limit: 38000
Uncompressed size: 202741 bytes

* 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.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thoughts on this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@joker23 joker23 force-pushed the skz/sdk-2043/rsc-bootstrap branch 6 times, most recently from 247bed3 to 4613301 Compare March 25, 2026 17:18
@joker23
Copy link
Copy Markdown
Contributor Author

joker23 commented Mar 25, 2026

@cursor review

cursor[bot]

This comment was marked as resolved.

@joker23 joker23 force-pushed the skz/sdk-2043/rsc-bootstrap branch 2 times, most recently from 8ae5305 to 2027d95 Compare March 25, 2026 17:36
* When provided, the client immediately uses these values before the first network
* response arrives — eliminating the flag-fetch waterfall on page load.
*/
bootstrap: unknown;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The typing here is to be consistent with browser sdk

@joker23
Copy link
Copy Markdown
Contributor Author

joker23 commented Mar 25, 2026

@cursor review

cursor[bot]

This comment was marked as resolved.

@joker23 joker23 force-pushed the skz/sdk-2043/rsc-bootstrap branch 2 times, most recently from 76d2c13 to 1edb021 Compare March 27, 2026 17:54
joker23 added 4 commits March 30, 2026 13:48
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
@joker23 joker23 force-pushed the skz/sdk-2043/rsc-bootstrap branch from 153d31a to e79ea73 Compare March 30, 2026 18:48
@joker23 joker23 marked this pull request as ready for review March 31, 2026 20:56
@joker23 joker23 requested a review from a team as a code owner March 31, 2026 20:56
devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

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