Flipt Client Browser

The flipt-client-browser
library contains the JavaScript/TypeScript source code for the Flipt client-side evaluation client for the browser.
Installation
npm install @flipt-io/flipt-client-browser
Usage
In your JavaScript/Typescript code you can import this client and use it as so:
import { FliptEvaluationClient } from '@flipt-io/flipt-client-browser';
const fliptEvaluationClient = await FliptEvaluationClient.init('default', {
url: 'http://localhost:8080',
authentication: {
client_token
}
});
const variant = fliptEvaluationClient.evaluateVariant('flag1', 'someentity', {
fizz: 'buzz'
});
console.log(variant);
State Management
The FliptEvaluationClient
class pulls flag state from the Flipt instance at the url
provided in the engine_opts
object on instantiation.
To update the flag state, you can call the refresh
method on the FliptEvaluationClient
class.
fliptEvaluationClient.refresh();
This allows you to update the flag state in a controlled manner, such as in a polling loop or when a user interacts with your application.
Development
WASM
This library uses a WebAssembly (WASM) layer to interact with the Flipt server. It is written in Rust and exposes a JavaScript API using the wasm-bindgen
and wasm-pack
tools. We wrap the built WASM layer in a JavaScript API to make it easier to use in a browser environment.
Prerequisites
Build
npm run build
Test
npm install
npm test