Skip to content

Comments

chore: create React SDK scaffold#1105

Open
joker23 wants to merge 3 commits intomainfrom
skz/init-react-sdk-scaffold
Open

chore: create React SDK scaffold#1105
joker23 wants to merge 3 commits intomainfrom
skz/init-react-sdk-scaffold

Conversation

@joker23
Copy link
Contributor

@joker23 joker23 commented Feb 17, 2026

sdk-1890

creating the initial scaffolding for React SDK.

This PR contains the interface definition to clarify some implementation details for the SDK


Note

Low Risk
Mostly scaffolding and type/interface definitions; the only implemented runtime logic is a thin wrapper (createReactServerClient) around existing server-client methods, with minimal behavior and clear input validation.

Overview
Introduces a new @launchdarkly/react-sdk workspace (and contract-tests workspace) and wires it into the monorepo workspaces, including TS/Typedoc config, placeholder tests, and initial README/temp docs marked experimental.

Defines the initial public surface area for the React SDK: client-side types/options and context provider helpers (with createClient/createContextFromClient stubbed), an isomorphic client interface with an opt-in useServerClient hook, and a server entrypoint createReactServerClient that wraps a common server LDClient to evaluate flags using a per-request contextProvider.

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

@joker23 joker23 requested a review from a team as a code owner February 17, 2026 23:11
@github-actions
Copy link
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25394 bytes
Compressed size limit: 26000
Uncompressed size: 124693 bytes

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 23336 bytes
Compressed size limit: 25000
Uncompressed size: 81070 bytes

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

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

[![NPM][npm-dm-badge]][npm-link]
[![NPM][npm-dt-badge]][npm-link]
-->
# LaunchDarkly React SDK
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Standard docs for now ... maybe put a redirect in the react-universal-sdk workspace?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, once we get further along we can redirect the old one. Or remove it and deprecate the package.

@joker23 joker23 force-pushed the skz/init-react-sdk-scaffold branch from a2dc44f to d35361d Compare February 17, 2026 23:17
[![NPM][npm-dm-badge]][npm-link]
[![NPM][npm-dt-badge]][npm-link]
-->
# LaunchDarkly React SDK
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, once we get further along we can redirect the old one. Or remove it and deprecate the package.

"typedoc": "0.25.0",
"typescript": "5.1.6"
},
"dependencies": {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there is a better way to handle these? I did the same thing in browser, even though they are bundled. Because if they are dev dependencies then the code completion and type checking don't really work.

I guess there isn't harm.

"@launchdarkly/node-server-sdk": "^9.4.6"
},
"peerDependencies": {
"react": ">=18.0.0"
Copy link
Member

Choose a reason for hiding this comment

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

Is this a good version? It probably is, but I feel like it would be good to have some justification information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point.. I'll start a doc directory here to put some things that could help development along... (and eventually docs team).

Net here is that server components were technically usable in v18 so the thinking is that it would lessen some compilation headaches even if three-shake is messed up... otherwise, I think react updates from 16 => 18 was relatively painless so declaring this version should also be mostly compatible if teams ignore peer deps (which they would most likely do if they are still on React < 18)

* @returns The browser side client.
*/
useBrowserClient: () => LDReactClient;
} No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

nit: A number of files are missing terminal newlines.

I wonder if we could get the linter to complain about the lack of newlines at the end of files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't set up linter 😭 ... planning on plugging into basic CI checks after getting the interface reviewed

/**
* The LaunchDarkly context.
*/
context: LDContext;
Copy link
Member

Choose a reason for hiding this comment

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

Interesting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thought here is to keep properties that do require a state update dispatch from the LDClient. Which is why I have:

  • context: so reidentifications can be dispatched
  • init state: so client can dispatch that it is in ready state

* A LaunchDarkly context object. If unspecified, an anonymous context
* with kind: 'user' will be created and used.
*/
context?: LDContext;
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure about this, but I suppose the old SDK did it. We may want to raise this one with the team.

@joker23 joker23 requested a review from kinyoklion February 18, 2026 17:33
@joker23 joker23 force-pushed the skz/init-react-sdk-scaffold branch from b292ba3 to a411b23 Compare February 18, 2026 20:49
@joker23 joker23 force-pushed the skz/init-react-sdk-scaffold branch from a411b23 to 1ee3e07 Compare February 18, 2026 22:50
@joker23 joker23 force-pushed the skz/init-react-sdk-scaffold branch from 1ee3e07 to 3922533 Compare February 19, 2026 00:26
* @returns The browser side client.
*/
useBrowserClient: () => LDReactClient;
}
Copy link

Choose a reason for hiding this comment

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

Isomorphic client interface is defined but unreachable

Low Severity

LDIsomorphicClient is exported from its own file but never re-exported from any package entry point (src/index.ts, src/client/index.ts, or src/server/index.ts). Since the package.json export map only exposes these three entry points, consumers of the package cannot access this interface. The server and client interfaces are properly exported from their respective entry points, but this central interface is missing.

Fix in Cursor Fix in Web

@joker23 joker23 force-pushed the skz/init-react-sdk-scaffold branch from 3922533 to cdd2797 Compare February 19, 2026 19:09
* if this is not provided.
*/
contextProvider: LDContextProvider;
}
Copy link

Choose a reason for hiding this comment

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

Server options interface misleadingly extends full SDK options

Low Severity

LDReactServerOptions extends LDOptionsCommon (the full server SDK options with 30+ properties like baseUri, streamUri, featureStore, bigSegments, tlsParams, etc.), but createReactServerClient only reads contextProvider from the options. The rest of the inherited properties are silently ignored since the function wraps an already-created LDClient. This creates a misleading API surface where developers might pass server configuration options expecting them to take effect.

Additional Locations (1)

Fix in Cursor Fix in Web

@joker23 joker23 force-pushed the skz/init-react-sdk-scaffold branch from cdd2797 to 00f3881 Compare February 19, 2026 19:38
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

client,
context,
intializedState: 'unknown',
});
Copy link

Choose a reason for hiding this comment

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

Client context factory returns null client

Medium Severity

createClientContext builds a React context using createClient, but createClient is currently a stub that returns null as any. This introduces a runtime footgun where consumers can receive a client value that is null and crash when calling LDClient methods.

Additional Locations (1)

Fix in Cursor Fix in Web

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