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: README.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -433,6 +433,32 @@ function MyComponent() {
433
433
</OptimizelyProvider>;
434
434
```
435
435
436
+
### Configuring the instance for server use
437
+
438
+
Server-side instances are short-lived (created per request) and may not be garbage collected immediately. To avoid unnecessary background work and ensure events are dispatched before the instance is discarded, configure `createInstance` with server-appropriate options:
|`datafileOptions.autoUpdate`|`false`| No need to poll for datafile updates on a per-request instance |
458
+
|`eventBatchSize`|`1`| Flush events immediately — the instance won't live long enough for a batch to fill |
459
+
|`eventMaxQueueSize`|`1`| Prevent event accumulation in a short-lived instance |
460
+
|`defaultDecideOptions`|`[DISABLE_DECISION_EVENT]`| Optional — avoids duplicate decision events if the client will also fire them after hydration |
461
+
436
462
### React Server Components
437
463
438
464
The SDK can also be used directly in React Server Components without `OptimizelyProvider`. Create an instance, set the user, wait for readiness, and make decisions — all within an `async` server component:
0 commit comments