npm.io
3.2.2 • Published 5 months ago

tggl-client

Licence
ISC
Version
3.2.2
Deps
2
Size
191 kB
Vulns
0
Weekly
0
Stars
3

Tggl Logo

Tggl Typescript SDK

The Typescript SDK can be used both on the client and server to evaluate flags and report usage to the Tggl API or a proxy.

Website Documentation NPM Videos

GitHub Workflow Status (with event) Coveralls branch npm

Usage

Install the dependency:

npm i tggl-client

Client applications (browsers, React Native, etc.) should use the TgglClient with a client API key:

import { TgglClient } from 'tggl-client'

const client = new TgglClient({
  apiKey: 'XXX',
  initialContext: { userId: 'abc123' },
})

await client.waitReady()

if (client.get('my-feature', true)) {
  // ...
}

Backend applications (NodeJs) should use the TgglLocalClient with a server API key:

import { TgglLocalClient } from 'tggl-client'

const client = new TgglLocalClient({
  apiKey: 'XXX',
})

await client.waitReady()

if (client.get({ userId: 'abc123' }, 'my-feature', true)) {
  // ...
}

Keywords