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/browser-sdk/README.md
+62-62Lines changed: 62 additions & 62 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,68 +113,6 @@ type Configuration = {
113
113
};
114
114
```
115
115
116
-
## Server-side rendering and bootstrapping
117
-
118
-
For server-side rendered applications, you can eliminate the initial network request by bootstrapping the client with pre-fetched flag data.
119
-
120
-
### Init options bootstrapped
121
-
122
-
```typescript
123
-
typeConfiguration= {
124
-
logger:console; // by default only logs warn/error, by passing `console` you'll log everything
125
-
apiBaseUrl?:"https://front.reflag.com";
126
-
sseBaseUrl?:"https://livemessaging.bucket.co";
127
-
feedback?:undefined; // See FEEDBACK.md
128
-
enableTracking?:true; // set to `false` to stop sending track events and user/company updates to Reflag servers. Useful when you're impersonating a user
129
-
offline?:boolean; // Use the SDK in offline mode. Offline mode is useful during testing and local development
130
-
bootstrappedFlags?:FetchedFlags; // Pre-fetched flags from server-side (see Server-side rendering section)
131
-
};
132
-
```
133
-
134
-
### Using bootstrappedFlags
135
-
136
-
Use the Node SDK's `getFlagsForBootstrap()` method to pre-fetch flags server-side, then pass them to the browser client:
Just as `isEnabled`, accessing `config` on the object returned by `getFlags` does not automatically
290
228
generate a `check` event, contrary to the `config` property on the object returned by `getFlag`.
291
229
230
+
## Server-side rendering and bootstrapping
231
+
232
+
For server-side rendered applications, you can eliminate the initial network request by bootstrapping the client with pre-fetched flag data.
233
+
234
+
### Init options bootstrapped
235
+
236
+
```typescript
237
+
typeConfiguration= {
238
+
logger:console; // by default only logs warn/error, by passing `console` you'll log everything
239
+
apiBaseUrl?:"https://front.reflag.com";
240
+
sseBaseUrl?:"https://livemessaging.bucket.co";
241
+
feedback?:undefined; // See FEEDBACK.md
242
+
enableTracking?:true; // set to `false` to stop sending track events and user/company updates to Reflag servers. Useful when you're impersonating a user
243
+
offline?:boolean; // Use the SDK in offline mode. Offline mode is useful during testing and local development
244
+
bootstrappedFlags?:FetchedFlags; // Pre-fetched flags from server-side (see Server-side rendering section)
245
+
};
246
+
```
247
+
248
+
### Using bootstrappedFlags
249
+
250
+
Use the Node SDK's `getFlagsForBootstrap()` method to pre-fetch flags server-side, then pass them to the browser client:
Attributes given for the user/company/other context in the ReflagClient constructor can be updated for use in flag targeting evaluation with the `updateUser()`, `updateCompany()` and `updateOtherContext()` methods.
> [!NOTE] > `user`/`company` attributes are also stored remotely on the Reflag servers and will automatically be used to evaluate flag targeting if the page is refreshed.
308
306
307
+
This eliminates loading states and improves performance by avoiding the initial flags API call.
308
+
309
309
## Toolbar
310
310
311
311
The Reflag Toolbar is great for toggling flags on/off for yourself to ensure that everything works both when a flag is on and when it's off.
0 commit comments