Skip to content

Commit 5d8e18b

Browse files
committed
chore: update readme
1 parent c2777c2 commit 5d8e18b

4 files changed

Lines changed: 130 additions & 127 deletions

File tree

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ npm install @replanejs/sdk
2424
```
2525

2626
```ts
27-
import { createReplaneClient } from "@replanejs/sdk";
27+
import { Replane } from "@replanejs/sdk";
2828

29-
const replane = await createReplaneClient({
29+
const replane = new Replane();
30+
await replane.connect({
3031
sdkKey: process.env.REPLANE_SDK_KEY!,
3132
baseUrl: "https://replane.example.com",
3233
});
@@ -110,15 +111,15 @@ npm install @replanejs/svelte
110111
```svelte
111112
<!-- +layout.svelte -->
112113
<script>
113-
import { ReplaneProvider, createReplaneClient } from "@replanejs/svelte";
114+
import { ReplaneContext } from "@replanejs/svelte";
115+
</script>
114116
115-
const client = await createReplaneClient({
117+
<ReplaneContext
118+
options={{
116119
baseUrl: "https://replane.example.com",
117120
sdkKey: "your-sdk-key",
118-
});
119-
</script>
120-
121-
<ReplaneContext {client}>
121+
}}
122+
>
122123
<slot />
123124
</ReplaneContext>
124125
```

packages/next/README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,22 @@ export function ConfigDisplay() {
176176

177177
## Client Options
178178

179-
The `options` prop accepts all options from `@replanejs/sdk`. Key options:
180-
181-
| Option | Type | Required | Description |
182-
| ------------------------- | ---------------------- | -------- | ------------------------------------------ |
183-
| `baseUrl` | `string` | Yes | Replane server URL |
184-
| `sdkKey` | `string` | Yes | SDK key for authentication |
185-
| `context` | `Record<string, any>` | No | Default context for override evaluations |
186-
| `defaults` | `Record<string, any>` | No | Default values if server is unavailable |
187-
| `required` | `string[]` or `object` | No | Configs that must exist for initialization |
188-
| `initializationTimeoutMs` | `number` | No | SDK initialization timeout (default: 5000) |
189-
190-
See [`@replanejs/sdk` documentation](https://github.com/replane-dev/replane-javascript/tree/main/packages/sdk#options) for the complete list of options.
179+
The `options` prop accepts the following options:
180+
181+
| Option | Type | Required | Description |
182+
| --------------------- | --------------------- | -------- | ---------------------------------------- |
183+
| `baseUrl` | `string` | Yes | Replane server URL |
184+
| `sdkKey` | `string` | Yes | SDK key for authentication |
185+
| `context` | `Record<string, any>` | No | Default context for override evaluations |
186+
| `defaults` | `Record<string, any>` | No | Default values if server is unavailable |
187+
| `connectTimeoutMs` | `number` | No | SDK connection timeout (default: 5000) |
188+
| `requestTimeoutMs` | `number` | No | Timeout for SSE requests (default: 2000) |
189+
| `retryDelayMs` | `number` | No | Base delay between retries (default: 200)|
190+
| `inactivityTimeoutMs` | `number` | No | SSE inactivity timeout (default: 30000) |
191+
| `fetchFn` | `typeof fetch` | No | Custom fetch implementation |
192+
| `logger` | `ReplaneLogger` | No | Custom logger (default: console) |
193+
194+
See [`@replanejs/sdk` documentation](https://github.com/replane-dev/replane-javascript/tree/main/packages/sdk#api) for more details.
191195

192196
## API Reference
193197

@@ -235,7 +239,7 @@ Returns the value of a config by name. Re-renders when the config changes.
235239
const theme = useConfig<{ darkMode: boolean }>("theme");
236240
```
237241

238-
#### `useReplane<T>(): ReplaneClient<T>`
242+
#### `useReplane<T>(): Replane<T>`
239243

240244
Returns the Replane client instance for advanced usage.
241245

packages/react/README.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,27 +75,32 @@ import { ErrorBoundary } from "react-error-boundary";
7575

7676
#### Client Options
7777

78-
The `options` prop accepts all options from `@replanejs/sdk`. Key options:
79-
80-
| Option | Type | Required | Description |
81-
| ------------------------- | ---------------------- | -------- | ------------------------------------------ |
82-
| `baseUrl` | `string` | Yes | Replane server URL |
83-
| `sdkKey` | `string` | Yes | SDK key for authentication |
84-
| `context` | `Record<string, any>` | No | Default context for override evaluations |
85-
| `defaults` | `Record<string, any>` | No | Default values if server is unavailable |
86-
| `required` | `string[]` or `object` | No | Configs that must exist for initialization |
87-
| `initializationTimeoutMs` | `number` | No | SDK initialization timeout (default: 5000) |
88-
89-
See [`@replanejs/sdk` documentation](https://github.com/replane-dev/replane-javascript/tree/main/packages/sdk#options) for the complete list of options.
78+
The `options` prop accepts the following options:
79+
80+
| Option | Type | Required | Description |
81+
| -------------------- | --------------------- | -------- | -------------------------------------------- |
82+
| `baseUrl` | `string` | Yes | Replane server URL |
83+
| `sdkKey` | `string` | Yes | SDK key for authentication |
84+
| `context` | `Record<string, any>` | No | Default context for override evaluations |
85+
| `defaults` | `Record<string, any>` | No | Default values if server is unavailable |
86+
| `connectTimeoutMs` | `number` | No | SDK connection timeout (default: 5000) |
87+
| `requestTimeoutMs` | `number` | No | Timeout for SSE requests (default: 2000) |
88+
| `retryDelayMs` | `number` | No | Base delay between retries (default: 200) |
89+
| `inactivityTimeoutMs`| `number` | No | SSE inactivity timeout (default: 30000) |
90+
| `fetchFn` | `typeof fetch` | No | Custom fetch implementation |
91+
| `logger` | `ReplaneLogger` | No | Custom logger (default: console) |
92+
93+
See [`@replanejs/sdk` documentation](https://github.com/replane-dev/replane-javascript/tree/main/packages/sdk#api) for more details.
9094

9195
#### 2. With pre-created client
9296

9397
Use this when you need more control over client lifecycle:
9498

9599
```tsx
96-
import { createReplaneClient } from "@replanejs/sdk";
100+
import { Replane } from "@replanejs/sdk";
97101

98-
const client = await createReplaneClient({
102+
const client = new Replane();
103+
await client.connect({
99104
baseUrl: "https://your-replane-server.com",
100105
sdkKey: "your-sdk-key",
101106
});
@@ -131,26 +136,24 @@ Restore a client from a snapshot obtained on the server. This is synchronous and
131136

132137
```tsx
133138
// On the server
134-
const serverClient = await createReplaneClient({ baseUrl: "...", sdkKey: "..." });
139+
const serverClient = new Replane();
140+
await serverClient.connect({ baseUrl: "...", sdkKey: "..." });
135141
const snapshot = serverClient.getSnapshot();
136142
// Pass snapshot to client via props, context, or serialized HTML
137143

138144
// On the client
139145
<ReplaneProvider
140-
restoreOptions={{
141-
snapshot,
142-
// Optional: connect for live updates
143-
connection: {
144-
baseUrl: "https://your-replane-server.com",
145-
sdkKey: "your-sdk-key",
146-
},
146+
options={{
147+
baseUrl: "https://your-replane-server.com",
148+
sdkKey: "your-sdk-key",
147149
}}
150+
snapshot={snapshot}
148151
>
149152
<App />
150153
</ReplaneProvider>;
151154
```
152155

153-
The restored client is immediately available with no loading state. If `connection` is provided, it will establish a connection for real-time updates in the background.
156+
The restored client is immediately available with no loading state. The provider will establish a connection for real-time updates in the background.
154157

155158
### useConfig
156159

0 commit comments

Comments
 (0)