> For the complete documentation index, see [llms.txt](https://developers.didomi.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.didomi.io/cmp/mobile-sdk/vega-os/setup.md).

# Setup

#### Installation

```bash
npm install @didomi/vega-sdk
```

#### Peer Dependencies

This SDK requires the following peer dependencies:

* `react` (>=18.0.0 <=18.2.0)
* `react-dom` (>=18.0.0 <=18.2.0)
* `react-native` (^0.72.0)
* `@amazon-devices/react-native-kepler` (^2.0.0)
* `@amazon-devices/webview`

> **Note:** For **WebView support**, update your app’s `manifest.toml` file to include the required Vega services.\
> Please refer to <https://developer.amazon.com/docs/vega/0.21/set-up-webview.html>

### Basic Integration

```tsx
import { DidomiSDK, DidomiSDKAPI } from '@didomi/vega-sdk';
import React, { useRef } from 'react';

const MyApp = () => {
  const didomiRef = useRef<DidomiSDKAPI>(null);

  return (
    <DidomiSDK
      noticeId="YOUR_NOTICE_ID"
      didomiPublicApiKey="YOUR_PUBLIC_API_KEY"
      ref={didomiRef}
      onReady={() => console.log('Didomi SDK is ready')}
      onConsentChanged={(consent) => console.log('Consent changed:', consent)}
    >
      {/* Your app content */}
      <YourApp />
    </DidomiSDK>
  );
};
```

***

### Programmatic Usage

All SDK functionality is exposed through the component `ref`:

```tsx
const didomiSDK = didomiRef.current;

// Display UI
didomiSDK?.notice.show();                  // Show consent notice
didomiSDK?.preferences.show('purposes');   // Show preferences dialog, the parameter is optional, and "vendors" can also be set to display the associated layer.

// Query SDK state
const isConsentRequired = await didomiSDK?.isConsentRequired();

// Manage user consent
const userStatus = await didomiSDK?.getCurrentUserStatus();
await didomiSDK?.setUserAgreeToAll();
await didomiSDK?.setCurrentUserStatus({
  purposes: { /* purpose status */ },
  vendors: { /* vendor status */ },
});
```

***

### API Reference

#### Component Props

| Prop                 | Type                     | Description                                                                      |
| -------------------- | ------------------------ | -------------------------------------------------------------------------------- |
| `noticeId`           | string                   | ID of the consent notice to display                                              |
| `didomiPublicApiKey` | string                   | Your Didomi **public API key**                                                   |
| `sdkPath`            | string                   | (Optional) Path to the Didomi SDK, defaults to `https://sdk.privacy-center.org/` |
| `onReady`            | `() => void`             | Fired when the SDK is initialized and ready.                                     |
| `onConsentChanged`   | `(consent: any) => void` | Fired whenever the user’s consent status changes.                                |

Other events are available as props, please refer to [Events](/cmp/mobile-sdk/vega-os/reference/events.md) for more details.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.didomi.io/cmp/mobile-sdk/vega-os/setup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
