New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@flipt-io/flipt-client-browser

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flipt-io/flipt-client-browser

Flipt Client Evaluation Browser SDK

  • 0.0.17
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
decreased by-24.5%
Maintainers
0
Weekly downloads
 
Created
Source

Flipt Client Browser

Status: Beta npm

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';

// namespace is the first positional argument and is optional here and will have a value of "default" if not specified.
// engine_opts is the second positional argument and is also optional, the structure is:
// {
//  "url": "http://localhost:8080",
//  "authentication": {
//    "client_token": "secret"
//  }
// }
//
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.

// Refresh the flag state
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

FAQs

Package last updated on 15 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc