Conversation
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/browser size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/js-client-sdk-common size report |
| [![NPM][npm-dm-badge]][npm-link] | ||
| [![NPM][npm-dt-badge]][npm-link] | ||
| --> | ||
| # LaunchDarkly React SDK |
There was a problem hiding this comment.
Standard docs for now ... maybe put a redirect in the react-universal-sdk workspace?
There was a problem hiding this comment.
Yeah, once we get further along we can redirect the old one. Or remove it and deprecate the package.
a2dc44f to
d35361d
Compare
| [![NPM][npm-dm-badge]][npm-link] | ||
| [![NPM][npm-dt-badge]][npm-link] | ||
| --> | ||
| # LaunchDarkly React SDK |
There was a problem hiding this comment.
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": { |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Is this a good version? It probably is, but I feel like it would be good to have some justification information.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I haven't set up linter 😭 ... planning on plugging into basic CI checks after getting the interface reviewed
| /** | ||
| * The LaunchDarkly context. | ||
| */ | ||
| context: LDContext; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
I am not sure about this, but I suppose the old SDK did it. We may want to raise this one with the team.
b292ba3 to
a411b23
Compare
a411b23 to
1ee3e07
Compare
1ee3e07 to
3922533
Compare
| * @returns The browser side client. | ||
| */ | ||
| useBrowserClient: () => LDReactClient; | ||
| } |
There was a problem hiding this comment.
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.
3922533 to
cdd2797
Compare
| * if this is not provided. | ||
| */ | ||
| contextProvider: LDContextProvider; | ||
| } |
There was a problem hiding this comment.
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)
cdd2797 to
00f3881
Compare
| client, | ||
| context, | ||
| intializedState: 'unknown', | ||
| }); |
There was a problem hiding this comment.
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.


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-sdkworkspace (andcontract-testsworkspace) 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/createContextFromClientstubbed), an isomorphic client interface with an opt-inuseServerClienthook, and a server entrypointcreateReactServerClientthat wraps a common serverLDClientto evaluate flags using a per-requestcontextProvider.Written by Cursor Bugbot for commit 00f3881. This will update automatically on new commits. Configure here.