Cobalt frontend SDK
npm install --save @cobaltio/cobalt-js @cobaltio/react-cobalt-js
// import Provider & Config components
import { Provider, Config } from "@cobaltio/react-cobalt-js";
// Config component needs to be wrapped inside the Provider component.
// And pass the Cobalt session token (that you generated using the Cobalt backend SDK) to the provider.
<Provider sessionToken={ cobaltToken }>
{
// ideally you'd render the Config component inside a modal.
// if no `slug` is provided, it'll show a list of all the enabled applications.
<Config
id="SOME_UNIQUE_CONFIG_ID" // Optional
slug="APP_SLUG" // application type / slug (optional)
// dynamic labels payload (optional)
labels={{ /* PAYLOAD */ }}
// you can override the component's container style if you want
style={{
borderRadius: 8,
maxWidth: 450,
}}
/>
}
</Provider>
For an example implementation, you can check out the App.js
file
in the example
directory.