Skip to content

Commit 3c9c833

Browse files
openfeaturebotZaimwa9
authored andcommitted
chore: update sdk readmes (#1324)
The PR was automatically generated via the update-sdk-docs GitHub workflow. Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com> Signed-off-by: wadii <wadii.zaim@flagsmith.com>
1 parent ef7ee8a commit 3c9c833

16 files changed

Lines changed: 99 additions & 25 deletions

File tree

docs/reference/sdks/client/kotlin.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This content has been automatically generated from kotlin-sdk.
1010
Edits should be made here: https://github.com/open-feature/kotlin-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Thu Dec 18 2025 08:11:39 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Wed Dec 24 2025 08:11:43 GMT+0000 (Coordinated Universal Time)
1414
-->
1515
import MCPInstall from '@site/src/partials/mcp-install';
1616

docs/reference/sdks/client/swift.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This content has been automatically generated from swift-sdk.
1010
Edits should be made here: https://github.com/open-feature/swift-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Thu Dec 18 2025 08:11:39 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Wed Dec 24 2025 08:11:43 GMT+0000 (Coordinated Universal Time)
1414
-->
1515
import MCPInstall from '@site/src/partials/mcp-install';
1616

docs/reference/sdks/client/web/angular.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
1010
Edits should be made here: https://github.com/open-feature/js-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Thu Dec 18 2025 08:11:39 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Wed Dec 24 2025 08:11:44 GMT+0000 (Coordinated Universal Time)
1414
-->
1515

1616
<p align="center" class="github-badges">

docs/reference/sdks/client/web/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
1010
Edits should be made here: https://github.com/open-feature/js-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Thu Dec 18 2025 08:11:39 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Wed Dec 24 2025 08:11:43 GMT+0000 (Coordinated Universal Time)
1414
-->
1515
import MCPInstall from '@site/src/partials/mcp-install';
1616

docs/reference/sdks/client/web/react.mdx

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
1010
Edits should be made here: https://github.com/open-feature/js-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Thu Dec 18 2025 08:11:39 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Wed Dec 24 2025 08:11:43 GMT+0000 (Coordinated Universal Time)
1414
-->
1515
import MCPInstall from '@site/src/partials/mcp-install';
1616

@@ -49,6 +49,8 @@ In addition to the feature provided by the [web sdk](/docs/reference/sdks/client
4949
- [Usage](#usage)
5050
- [OpenFeatureProvider context provider](#openfeatureprovider-context-provider)
5151
- [Evaluation hooks](#evaluation-hooks)
52+
- [Declarative components](#declarative-components)
53+
- [FeatureFlag Component](#featureflag-component)
5254
- [Multiple Providers and Domains](#multiple-providers-and-domains)
5355
- [Re-rendering with Context Changes](#re-rendering-with-context-changes)
5456
- [Re-rendering with Flag Configuration Changes](#re-rendering-with-flag-configuration-changes)
@@ -168,6 +170,68 @@ import { useBooleanFlagDetails } from '@openfeature/react-sdk';
168170
const { value, variant, reason, flagMetadata } = useBooleanFlagDetails('new-message', false);
169171
```
170172

173+
#### Declarative components
174+
175+
The React SDK includes declarative components for feature flagging that provide a more JSX-native approach to conditional rendering.
176+
177+
##### FeatureFlag Component
178+
179+
The `FeatureFlag` component conditionally renders its children based on feature flag evaluation:
180+
181+
```tsx
182+
import { FeatureFlag } from '@openfeature/react-sdk';
183+
184+
function App() {
185+
return (
186+
<OpenFeatureProvider>
187+
{/* Basic usage - renders children when flag is truthy */}
188+
<FeatureFlag flagKey="new-feature" defaultValue={false}>
189+
<NewFeatureComponent />
190+
</FeatureFlag>
191+
192+
{/* Match specific values */}
193+
<FeatureFlag flagKey="theme" matchValue="dark" defaultValue="light">
194+
<DarkThemeStyles />
195+
</FeatureFlag>
196+
197+
{/* Boolean flag with fallback */}
198+
<FeatureFlag flagKey="premium-feature" matchValue={true} defaultValue={false} fallback={<UpgradePrompt />}>
199+
<PremiumContent />
200+
</FeatureFlag>
201+
202+
{/* Custom predicate function for complex matching */}
203+
<FeatureFlag
204+
flagKey="user-segment"
205+
defaultValue=""
206+
matchValue="beta"
207+
// check if the actual flag value includes the match ('beta')
208+
predicate={(expected, actual) => !!expected && actual.value.includes(expected)}
209+
>
210+
<BetaFeatures />
211+
</FeatureFlag>
212+
213+
{/* Function as children for accessing flag details */}
214+
<FeatureFlag flagKey="experiment" defaultValue="control" matchValue="beta">
215+
{({ value, reason }) => (
216+
<span>
217+
value is {value}, reason is {reason?.toString()}
218+
</span>
219+
)}
220+
</FeatureFlag>
221+
</OpenFeatureProvider>
222+
);
223+
}
224+
```
225+
226+
The `FeatureFlag` component supports the following props:
227+
228+
- **`flagKey`** (required): The feature flag key to evaluate
229+
- **`defaultValue`** (required): Default value when the flag is not available
230+
- **`matchValue`** (required, except for boolean flags): Value to match against the flag value. By default, an optimized deep-comparison function is used.
231+
- **`predicate`** (optional): Custom function for matching logic that receives the expected value and evaluation details
232+
- **`children`**: Content to render when condition is met (can be JSX or a function receiving flag details)
233+
- **`fallback`** (optional): Content to render when condition is not met
234+
171235
#### Multiple Providers and Domains
172236

173237
Multiple providers can be used by passing a `domain` to the `OpenFeatureProvider`:
@@ -310,8 +374,8 @@ The [OpenFeature debounce hook](https://github.com/open-feature/js-sdk-contrib/t
310374
### Testing
311375

312376
The React SDK includes a built-in context provider for testing.
313-
This allows you to easily test components that use evaluation hooks, such as `useFlag`.
314-
If you try to test a component (in this case, `MyComponent`) which uses an evaluation hook, you might see an error message like:
377+
This allows you to easily test components that use evaluation hooks (such as `useFlag`) or declarative components (such as `FeatureFlag`).
378+
If you try to test a component (in this case, `MyComponent`) which uses feature flags, you might see an error message like:
315379

316380
> No OpenFeature client available - components using OpenFeature must be wrapped with an `<OpenFeatureProvider>`.
317381
@@ -332,6 +396,16 @@ If you'd like to control the values returned by the evaluation hooks, you can pa
332396
<OpenFeatureTestProvider flagValueMap={{ 'my-boolean-flag': true }}>
333397
<MyComponent />
334398
</OpenFeatureTestProvider>
399+
400+
// testing declarative FeatureFlag components
401+
<OpenFeatureTestProvider flagValueMap={{ 'new-feature': true, 'theme': 'dark' }}>
402+
<FeatureFlag flagKey="new-feature" defaultValue={false}>
403+
<NewFeature />
404+
</FeatureFlag>
405+
<FeatureFlag flagKey="theme" match="dark" defaultValue="light">
406+
<DarkMode />
407+
</FeatureFlag>
408+
</OpenFeatureTestProvider>
335409
```
336410

337411
Additionally, you can pass an artificial delay for the provider startup to test your suspense boundaries or loaders/spinners impacted by feature flags:

docs/reference/sdks/server/dart.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This content has been automatically generated from dart-server-sdk.
99
Edits should be made here: https://github.com/open-feature/dart-server-sdk
1010
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1111

12-
Last updated at Thu Dec 18 2025 08:11:39 GMT+0000 (Coordinated Universal Time)
12+
Last updated at Wed Dec 24 2025 08:11:44 GMT+0000 (Coordinated Universal Time)
1313
-->
1414

1515
<p align="center" class="github-badges">

docs/reference/sdks/server/dotnet.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ This content has been automatically generated from dotnet-sdk.
1010
Edits should be made here: https://github.com/open-feature/dotnet-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Thu Dec 18 2025 08:11:39 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Wed Dec 24 2025 08:11:43 GMT+0000 (Coordinated Universal Time)
1414
-->
1515
import MCPInstall from '@site/src/partials/mcp-install';
1616

1717

1818
[![Specification](https://img.shields.io/static/v1?label=specification&message=v0.8.0&color=yellow&style=for-the-badge)](https://github.com/open-feature/spec/releases/tag/v0.8.0)
1919
[
20-
![Release](https://img.shields.io/static/v1?label=release&message=v2.10.0&color=blue&style=for-the-badge)
21-
](https://github.com/open-feature/dotnet-sdk/releases/tag/v2.10.0)
20+
![Release](https://img.shields.io/static/v1?label=release&message=v2.11.0&color=blue&style=for-the-badge)
21+
](https://github.com/open-feature/dotnet-sdk/releases/tag/v2.11.0)
2222

2323
[![Slack](https://img.shields.io/badge/slack-%40cncf%2Fopenfeature-brightgreen?style=flat&logo=slack)](https://cloud-native.slack.com/archives/C0344AANLA1)
2424
[![Codecov](https://codecov.io/gh/open-feature/dotnet-sdk/branch/main/graph/badge.svg?token=MONAVJBXUJ)](https://codecov.io/gh/open-feature/dotnet-sdk)

docs/reference/sdks/server/go.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This content has been automatically generated from go-sdk.
99
Edits should be made here: https://github.com/open-feature/go-sdk
1010
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1111

12-
Last updated at Thu Dec 18 2025 08:11:39 GMT+0000 (Coordinated Universal Time)
12+
Last updated at Wed Dec 24 2025 08:11:43 GMT+0000 (Coordinated Universal Time)
1313
-->
1414
import MCPInstall from '@site/src/partials/mcp-install';
1515

docs/reference/sdks/server/java.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This content has been automatically generated from java-sdk.
99
Edits should be made here: https://github.com/open-feature/java-sdk
1010
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1111

12-
Last updated at Thu Dec 18 2025 08:11:38 GMT+0000 (Coordinated Universal Time)
12+
Last updated at Wed Dec 24 2025 08:11:43 GMT+0000 (Coordinated Universal Time)
1313
-->
1414
import MCPInstall from '@site/src/partials/mcp-install';
1515

docs/reference/sdks/server/javascript/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
1010
Edits should be made here: https://github.com/open-feature/js-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Thu Dec 18 2025 08:11:38 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Wed Dec 24 2025 08:11:43 GMT+0000 (Coordinated Universal Time)
1414
-->
1515
import MCPInstall from '@site/src/partials/mcp-install';
1616

0 commit comments

Comments
 (0)