added
Hyphen Browser SDK for Toggle v1 🎉
about 6 hours ago by Jared Wray
We now provide a javascript framework for frameworks such as react, svelte, and more. This new sdk is now downloadable from the web. You can read more about it here: https://www.jsdelivr.com/package/npm/@hyphen/browser-sdk
Here is an example on how it works:
import { Toggle } from '@hyphen/browser-sdk';
// Initialize the Toggle client
const toggle = new Toggle({
publicApiKey: 'public_your-api-key-here',
applicationId: 'your-app-id',
environment: 'production', // or 'development'
defaultContext: {
targetingKey: 'user-123',
user: {
id: 'user-123',
email: '[email protected]',
name: 'John Doe'
}
}
});
const welcomeMessage = await toggle.getString('welcome-message', 'Hello World');
document.getElementById('welcome').textContent = welcomeMessage;