You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/sdk/cloudflare/README.md
+13-2Lines changed: 13 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,14 @@ For more information, see the [complete reference guide for this SDK](https://do
15
15
## Install
16
16
17
17
```shell
18
+
# npm
18
19
npm i @launchdarkly/cloudflare-server-sdk
20
+
21
+
# yarn
22
+
yarn add @launchdarkly/cloudflare-server-sdk
23
+
24
+
# jsr
25
+
npx jsr add @launchdarkly/cloudflare-server-sdk
19
26
```
20
27
21
28
Then turn on the Node.js compatibility flag in your `wrangler.toml`. This allows the SDK to use `node:events`:
@@ -24,6 +31,10 @@ Then turn on the Node.js compatibility flag in your `wrangler.toml`. This allows
24
31
compatibility_flags = [ "nodejs_compat" ]
25
32
```
26
33
34
+
## Additional JSR setup
35
+
36
+
If you want to install this package as a JSR package, you will need to use [`esbuild` version >= 19.7](https://github.com/evanw/esbuild/releases/tag/v0.19.7) to enable support for `import attributes`.
37
+
27
38
## Quickstart
28
39
29
40
Initialize the ldClient with your client side sdk key and the [Cloudflare KV namespace](https://developers.cloudflare.com/workers/runtime-apis/kv#kv-bindings):
@@ -33,12 +44,12 @@ import { init as initLD } from '@launchdarkly/cloudflare-server-sdk';
3. Insert test data to the preview environment. You must use your own clientSideID and prefix it with `LD-Env-`. In the example below, the clientSideID is `test-client-side-id`. Internally, the Cloudflare SDK uses this `LD-Env-` namespace to distinguish LaunchDarkly data from others.
29
29
30
30
```shell
31
-
# The Cloudflare SDK automatically adds the "LD-Env-" prefix to your sdk key
32
-
npx wrangler kv:key put --binding=LD_KV "LD-Env-test-sdk-key" --path ./src/testData.json --preview
31
+
npx wrangler kv:key put --binding=LD_KV "LD-Env-test-client-side-id" --path ./src/testData.json --preview
33
32
```
34
33
35
34
4. View that test data to ensure it's present:
36
35
37
36
```shell
38
-
npx wrangler kv:key get --binding=LD_KV "LD-Env-test-sdk-key" --preview
37
+
npx wrangler kv:key get --binding=LD_KV "LD-Env-test-client-side-id" --preview
39
38
```
40
39
41
-
5. Finally:
40
+
5. Edit [index.ts](https://github.com/launchdarkly/js-core/blob/main/packages/sdk/cloudflare/example/src/index.ts#L6) to use your clientSideID and a valid flag key from the test data you just inserted.
0 commit comments