JavaScript quickstart
Use the browser SDK when a web app reads flags for one user at a time. Get your public client key from SDK keys in the panel. Start with the environment where you can test a release.
npm install @dipswitch/sdk-js
import { createClient } from '@dipswitch/sdk-js'
const flags = createClient({ clientKey: 'ds_client_...', user: { id: 'user-42' } })
await flags.ready
function render() {
document.body.classList.toggle('new-checkout', flags.isEnabled('new-checkout', false))
}
render()
const stop = flags.onChange(render)
export const switchUser = (id: string) => flags.identify({ id })
export const signOut = () => flags.identify(undefined)
export const dispose = () => { stop(); flags.close() }
Pass no user for signed-out pages. During a user switch, the SDK reads the new user's cached flags if available and otherwise uses your defaults. See Verify user identity if the environment requires a signature.