Skip to content

Commit 1666597

Browse files
beeme1mrtoddbaert
andauthored
docs: update react readme (#792)
Signed-off-by: Michael Beemer <[email protected]> Co-authored-by: Todd Baert <[email protected]>
1 parent c47c7d9 commit 1666597

File tree

1 file changed

+57
-14
lines changed

1 file changed

+57
-14
lines changed

packages/react/README.md

+57-14
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,66 @@
1515
<a href="https://github.com/open-feature/spec/releases/tag/v0.7.0">
1616
<img alt="Specification" src="https://img.shields.io/static/v1?label=specification&message=v0.7.0&color=yellow&style=for-the-badge" />
1717
</a>
18+
<!-- x-release-please-start-version -->
19+
<a href="https://github.com/open-feature/js-sdk/releases/tag/react-sdk-v0.1.0-experimental">
20+
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v0.1.0-experimental&color=blue&style=for-the-badge" />
21+
</a>
22+
<!-- x-release-please-end -->
1823
<br/>
1924
<a href="https://codecov.io/gh/open-feature/js-sdk">
2025
<img alt="codecov" src="https://codecov.io/gh/open-feature/js-sdk/branch/main/graph/badge.svg?token=3DC5XOEHMY" />
2126
</a>
27+
<a href="https://www.npmjs.com/package/@openfeature/react-sdk">
28+
<img alt="NPM Download" src="https://img.shields.io/npm/dm/%40openfeature%2Freact-sdk" />
29+
</a>
2230
</p>
2331
<!-- x-hide-in-docs-start -->
2432

25-
[OpenFeature](https://openfeature.dev) is an open specification that provides a vendor-agnostic, community-driven API for feature flagging that works with your favorite feature flag management tool.
33+
[OpenFeature](https://openfeature.dev) is an open specification that provides a vendor-agnostic, community-driven API for feature flagging that works with your favorite feature flag management tool or in-house solution.
34+
35+
<!-- x-hide-in-docs-end -->
2636

2737
🧪 This SDK is experimental.
2838

29-
## Basic Usage
39+
## Overview
40+
41+
The OpenFeature React SDK adds React-specific functionality to the [OpenFeature Web SDK](https://openfeature.dev/docs/reference/technologies/client/web).
42+
43+
In addition to the feature provided by the [web sdk](https://openfeature.dev/docs/reference/technologies/client/web), capabilities include:
44+
45+
- [Multiple Providers and Scoping](#multiple-providers-and-scoping)
46+
- [Re-rendering with Context Changes](#re-rendering-with-context-changes)
47+
- [Re-rendering with Flag Configuration Changes](#re-rendering-with-flag-configuration-changes)
48+
- [Suspense Support](#suspense-support)
49+
50+
## 🚀 Quick start
51+
52+
### Requirements
53+
54+
- ES2022-compatible web browser (Chrome, Edge, Firefox, etc)
55+
- React version 16.8+
3056

31-
Here's a basic example of how to use the current API with the in-memory provider:
57+
### Install
58+
59+
#### npm
60+
61+
```sh
62+
npm install --save @openfeature/react-sdk
63+
```
64+
65+
#### Required peer dependencies
66+
67+
The following list contains the peer dependencies of `@openfeature/react-sdk` with its expected and compatible versions:
68+
69+
* `@openfeature/web-sdk`: >=0.4.10
70+
* `react`: >=16.8.0
71+
72+
### Usage
73+
74+
The example below shows how to use the `OpenFeatureProvider` with OpenFeature's `InMemoryProvider`.
3275

3376
```tsx
34-
import logo from './logo.svg';
35-
import './App.css';
36-
import { EvaluationContext, OpenFeatureProvider, useBooleanFlagValue, useBooleanFlagDetails, OpenFeature } from '@openfeature/react-sdk';
37-
import { FlagdWebProvider } from '@openfeature/flagd-web-provider';
77+
import { EvaluationContext, OpenFeatureProvider, useBooleanFlagValue, useBooleanFlagDetails, OpenFeature, InMemoryProvider } from '@openfeature/react-sdk';
3878

3979
const flagConfig = {
4080
'new-message': {
@@ -68,7 +108,6 @@ function Page() {
68108
return (
69109
<div className="App">
70110
<header className="App-header">
71-
<img src={logo} className="App-logo" alt="logo" />
72111
{newMessage ? <p>Welcome to this OpenFeature-enabled React app!</p> : <p>Welcome to this React app.</p>}
73112
</header>
74113
</div>
@@ -81,14 +120,14 @@ export default App;
81120
You use the detailed flag evaluation hooks to evaluate the flag and get additional information about the flag and the evaluation.
82121

83122
```tsx
84-
import { useBooleanFlagDetails} from '@openfeature/react-sdk';
123+
import { useBooleanFlagDetails } from '@openfeature/react-sdk';
85124

86125
const {
87-
value,
88-
variant,
89-
reason,
90-
flagMetadata
91-
} = useBooleanFlagDetails('new-message', false);
126+
value,
127+
variant,
128+
reason,
129+
flagMetadata
130+
} = useBooleanFlagDetails('new-message', false);
92131
```
93132

94133
### Multiple Providers and Scoping
@@ -182,3 +221,7 @@ function Fallback() {
182221
return <p>Waiting for provider to be ready...</p>;
183222
}
184223
```
224+
225+
## Resources
226+
227+
- [Example repo](https://github.com/open-feature/react-test-app)

0 commit comments

Comments
 (0)