--- title: "Web CMP SDK" slug: "web-cmp-sdk" updated: 2026-11-17T04:57:35Z published: 2026-11-17T04:57:35Z canonical: "usercentrics.com/web-cmp-sdk" --- > ## Documentation Index > Fetch the complete documentation index at: https://usercentrics.com/docs/llms.txt > Use this file to discover all available pages before exploring further. # Web CMP SDK ## Introduction With the Usercentrics Web CMP SDK our aim is to provide a lightweight library which enables you to build your own fully customiziable Consent Solution, while still leveraging the backend infrastructure that we provide at Usercentrics. > **Tip** > > > Follow this guide in order to have the Browser SDK fully prepared for your own UI design in no time. > **Note** > > > Looking for supported attributes? You can find them in the following links: > > > - [Classes](/v1/docs/web-cmp-sdk-classes) > - [Enums](/v1/docs/web-cmp-sdk-enums) > - [Interfaces](/v1/docs/web-cmp-sdk-interfaces) > - [Types](/v1/docs/web-cmp-sdk-types) ## Integrate the Browser SDK ### Installing the dependency For starters, you will need to install the dependency. For that use the following command: ```bash npm install @usercentrics/cmp-web-sdk --save ``` ### Creating the Browser SDK Instance To initialize the BrowserSDK class, please use the following: #### Without InitOptions ```typescript import { BrowserSdk } from '@usercentrics/cmp-web-sdk'; const browserSdk = new BrowserSdk(); ``` #### With InitOptions > **Note** > > > InitOptions definition available [here](/docs/web-cmp-sdk#initoptions) ```typescript import { BrowserSdk } from '@usercentrics/cmp-web-sdk'; const initOptions = {  disableTracking: false,  euMode: true,  language: "en",  location: {    country: "DE",    region: "BY",    city: "",  },  sandbox: false } const browserSdk = new BrowserSdk(initOptions); ``` ### Initialize Now with the BrowserSDK instance we can initialize the SDK. There are two methods you can choose between on how to initialize the SDK: via RulesetId or SettingsId. > **Note** > > > Both methods can also receive the controllerId as an optional parameter #### SettingsId ```typescript const settingsId = "/* YOUR SETTINGSID */"; const controllerId = "/* OPTIONAL CONTROLLER ID */" const cmpController = await browserSdk.initBySetting(settingsId); const cmpController = await browserSdk.initBySetting(settingsId, controllerId); ``` #### RulesetId ```typescript const rulesetId = "/* YOUR RULESETID */"; const controllerId = "/* OPTIONAL CONTROLLER ID */" const cmpController = await browserSdk.initByRuleSet(rulesetId); const cmpController = await browserSdk.initByRuleSet(rulesetId, controllerId); ``` ## Using the Browser SDK ### Getting the initial view Now that you have your `cmpController` ready, you can check which view you should show. ```typescript const { ui } = cmpController; switch (ui.initialView) {  case 'button':    // Show the Privacy Button    break;  case 'first':    // Show the First Layer    break;  case 'second':    // Show the Second Layer    break;  default:    break; } ```