@@ -29,7 +29,7 @@ import { ReplaneProvider, useConfig } from "@replanejs/react";
2929function App() {
3030 return (
3131 <ReplaneProvider
32- options = { {
32+ connection = { {
3333 baseUrl: " https://your-replane-server.com" ,
3434 sdkKey: " your-sdk-key" ,
3535 }}
@@ -51,9 +51,9 @@ function MyComponent() {
5151
5252### ReplaneProvider
5353
54- Provider component that makes the Replane client available to your component tree. Supports four usage patterns:
54+ Provider component that makes the Replane client available to your component tree. Supports multiple usage patterns:
5555
56- #### 1. With options (recommended)
56+ #### 1. With connection (recommended)
5757
5858The provider creates and manages the client internally. Use an Error Boundary to handle initialization errors:
5959
@@ -62,7 +62,7 @@ import { ErrorBoundary } from "react-error-boundary";
6262
6363<ErrorBoundary fallback = { <div >Failed to load configuration</div >} >
6464 <ReplaneProvider
65- options = { {
65+ connection = { {
6666 baseUrl: " https://your-replane-server.com" ,
6767 sdkKey: " your-sdk-key" ,
6868 }}
@@ -73,22 +73,32 @@ import { ErrorBoundary } from "react-error-boundary";
7373</ErrorBoundary >;
7474```
7575
76- #### Client Options
76+ #### Provider Props
7777
78- The ` options ` prop accepts the following options:
78+ | Prop | Type | Required | Description |
79+ | ------------ | --------------------------- | -------- | ------------------------------------------------------- |
80+ | ` connection ` | ` ConnectOptions \| null ` | Yes | Connection options (see below), or ` null ` to skip connection |
81+ | ` defaults ` | ` Record<string, unknown> ` | No | Default values if server is unavailable |
82+ | ` context ` | ` Record<string, unknown> ` | No | Default context for override evaluations |
83+ | ` snapshot ` | ` ReplaneSnapshot ` | No | Snapshot for SSR hydration |
84+ | ` logger ` | ` ReplaneLogger ` | No | Custom logger (default: console) |
85+ | ` loader ` | ` ReactNode ` | No | Component to show while loading |
86+ | ` suspense ` | ` boolean ` | No | Use React Suspense for loading state |
87+ | ` async ` | ` boolean ` | No | Connect asynchronously (renders immediately with defaults) |
88+
89+ #### Connection Options
90+
91+ The ` connection ` prop accepts the following options:
7992
8093| Option | Type | Required | Description |
8194| -------------------- | --------------------- | -------- | -------------------------------------------- |
8295| ` baseUrl ` | ` string ` | Yes | Replane server URL |
8396| ` 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 |
8697| ` connectTimeoutMs ` | ` number ` | No | SDK connection timeout (default: 5000) |
8798| ` requestTimeoutMs ` | ` number ` | No | Timeout for SSE requests (default: 2000) |
8899| ` retryDelayMs ` | ` number ` | No | Base delay between retries (default: 200) |
89100| ` inactivityTimeoutMs ` | ` number ` | No | SSE inactivity timeout (default: 30000) |
90101| ` fetchFn ` | ` typeof fetch ` | No | Custom fetch implementation |
91- | ` logger ` | ` ReplaneLogger ` | No | Custom logger (default: console) |
92102
93103See [ ` @replanejs/sdk ` documentation] ( https://github.com/replane-dev/replane-javascript/tree/main/packages/sdk#api ) for more details.
94104
@@ -118,7 +128,7 @@ Integrates with React Suspense for loading states:
118128<ErrorBoundary fallback = { <div >Failed to load configuration</div >} >
119129 <Suspense fallback = { <LoadingSpinner />} >
120130 <ReplaneProvider
121- options = { {
131+ connection = { {
122132 baseUrl: " https://your-replane-server.com" ,
123133 sdkKey: " your-sdk-key" ,
124134 }}
@@ -130,7 +140,24 @@ Integrates with React Suspense for loading states:
130140</ErrorBoundary >
131141```
132142
133- #### 4. With snapshot (for SSR/hydration)
143+ #### 4. With async mode
144+
145+ Connect in the background while rendering immediately with defaults:
146+
147+ ``` tsx
148+ <ReplaneProvider
149+ connection = { {
150+ baseUrl: " https://your-replane-server.com" ,
151+ sdkKey: " your-sdk-key" ,
152+ }}
153+ defaults = { { featureEnabled: false }}
154+ async
155+ >
156+ <App />
157+ </ReplaneProvider >
158+ ```
159+
160+ #### 5. With snapshot (for SSR/hydration)
134161
135162Restore a client from a snapshot obtained on the server. This is synchronous and useful for SSR scenarios:
136163
@@ -143,7 +170,7 @@ const snapshot = serverClient.getSnapshot();
143170
144171// On the client
145172<ReplaneProvider
146- options = { {
173+ connection = { {
147174 baseUrl: " https://your-replane-server.com" ,
148175 sdkKey: " your-sdk-key" ,
149176 }}
@@ -353,7 +380,7 @@ class ErrorBoundary extends Component<
353380
354381// Usage
355382<ErrorBoundary fallback = { <div >Configuration failed to load</div >} >
356- <ReplaneProvider options = { options } loader = { <Loading />} >
383+ <ReplaneProvider connection = { connection } loader = { <Loading />} >
357384 <App />
358385 </ReplaneProvider >
359386</ErrorBoundary >;
@@ -373,7 +400,7 @@ import { ErrorBoundary } from "react-error-boundary";
373400 )}
374401 onReset = { () => clearSuspenseCache ()}
375402>
376- <ReplaneProvider options = { options } loader = { <Loading />} >
403+ <ReplaneProvider connection = { connection } loader = { <Loading />} >
377404 <App />
378405 </ReplaneProvider >
379406</ErrorBoundary >;
0 commit comments