# @go-trust/mobile-sdk

> GoTrust consent management SDK for React Native

Latest version **1.0.3** (published 2026-09-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @go-trust/mobile-sdk
pnpm add @go-trust/mobile-sdk
yarn add @go-trust/mobile-sdk
bun add @go-trust/mobile-sdk
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2026-09-24 |
| First published | 2026-09-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 287.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | GoTrust |
| Maintainers | devtekhsters |
| Keywords | react-native, ios, android, consent, privacy, dpdp, consent-management, gotrust |

## Links

- npm: https://www.npmjs.com/package/@go-trust/mobile-sdk
- Homepage: https://gotrust.tech
- npm.io page: https://npm.io/package/@go-trust/mobile-sdk

## Dependencies (1)

- [@dagrejs/dagre](https://npm.io/package/@dagrejs/dagre.md) ^3.1.1

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2026-09-24
- 1.0.2 — 2026-09-24
- 1.0.0 — 2026-09-24

## README

# @go-trust/mobile-sdk

GoTrust consent management SDK for React Native. Show consent forms and let users manage their consent preferences inside your app.

## Installation

Install the SDK along with its required peer dependencies:

```bash
npm install @go-trust/mobile-sdk @react-native-async-storage/async-storage react-native-webview
```

For iOS, install the pods:

```bash
cd ios && pod install && cd ..
```

Then rebuild your app. A Metro reload is not enough, because native modules were added:

```bash
npx react-native run-android
# or
npx react-native run-ios
```

## Setup

Render the SDK root components once, near the root of your app. They host the consent screens.

```tsx
import { GoTrustSdkRoot, GoTrustPreferencesRoot } from '@go-trust/mobile-sdk';

export default function App() {
  return (
    <View style={{ flex: 1 }}>
      {/* your app */}
      <GoTrustSdkRoot />
      <GoTrustPreferencesRoot />
    </View>
  );
}
```

## Consent form

Call `checkConsentStatus` first. It checks whether the user already has consent on record and returns `true` only when the form should be shown.

```tsx
import { checkConsentStatus, showConsentForm } from '@go-trust/mobile-sdk';

const openConsentForm = async () => {
  const shouldShow = await checkConsentStatus({
    baseUrl: 'YOUR_BASE_URL',
    sourceId: 'YOUR_SOURCE_ID',
    token: 'USER_SPECIFIC_CONSENT_TOKEN',
    subjectIdentityValues: { YOUR_FIELD_ID: 'YOUR_FIELD_VALUE' },
    dynamicConsent: true,
  });

  if (!shouldShow) {
    return; // consent already exists
  }

  showConsentForm({
    baseUrl: 'YOUR_BASE_URL',
    sourceId: 'YOUR_SOURCE_ID',
    token: 'USER_SPECIFIC_CONSENT_TOKEN',
    subjectIdentityValues: { YOUR_FIELD_ID: 'YOUR_FIELD_VALUE' },
    additionalParams: { YOUR_FIELD_ID: 'YOUR_FIELD_VALUE' },
    showCrossButton: true,
    enableCaptcha: false,
    callbacks: {
      onSuccess: () => console.log('Consent submitted'),
      onError: (error) => console.log('Consent error', error),
      onClose: () => console.log('Consent form closed by user'),
      onNothingTapped: (message) => {
        // Your own logic for buttons configured with the "nothing" action.
        // The form stays open while this runs.
        console.log('Client action triggered', message);
      },
    },
  });
};
```

### `checkConsentStatus` options

| Option | Description |
| --- | --- |
| `baseUrl` | Your GoTrust API base URL. |
| `sourceId` | The consent source ID. |
| `token` | User-specific consent token. |
| `subjectIdentityValues` | Identity values of the current user, keyed by field ID. |
| `dynamicConsent` | Enables dynamic consent checking. |
| `debug` | Enables debug logging. |

Returns a `Promise<boolean>`: `true` if the consent form should be shown.

### `showConsentForm` options

| Option | Description |
| --- | --- |
| `baseUrl` | Your GoTrust API base URL. |
| `sourceId` | The consent source ID. |
| `token` | User-specific consent token. |
| `subjectIdentityValues` | Identity values of the current user, keyed by field ID. |
| `additionalParams` | Extra field values to send with the consent. |
| `showCrossButton` | Shows a close (×) button on the form. |
| `enableCaptcha` | Enables the reCAPTCHA step. |
| `debug` | Enables debug logging. |
| `callbacks.onSuccess` | Called when consent is submitted. |
| `callbacks.onError` | Called with the error when something fails. |
| `callbacks.onClose` | Called when the user closes the form. |
| `callbacks.onNothingTapped` | Called when a button configured with the "nothing" action is tapped. The form stays open. |

## Consent preferences

```tsx
import { showConsentPreferences } from '@go-trust/mobile-sdk';

showConsentPreferences({
  baseUrl: 'YOUR_BASE_URL',
  customerId: 'YOUR_CUSTOMER_ID',
  preferenceFormId: 'YOUR_PREFERENCE_FORM_ID',
  token: 'USER_SPECIFIC_PREFERENCE_TOKEN',
  subjectIdentityValues: { YOUR_FIELD_ID: 'YOUR_FIELD_VALUE' },
  callbacks: {
    onSuccess: () => console.log('Preferences saved'),
    onError: (error) => console.log('Preferences error', error),
    onClose: () => console.log('Preferences closed by user'),
  },
});
```

If `customerId` and `preferenceFormId` aren't available on the client, pass `pfToken` instead and they will be resolved server-side.

### `showConsentPreferences` options

| Option | Description |
| --- | --- |
| `baseUrl` | Your GoTrust API base URL. |
| `customerId` | Your GoTrust customer ID. |
| `preferenceFormId` | The preference form to display. |
| `pfToken` | Alternative to `customerId` and `preferenceFormId`, resolved server-side. |
| `token` | User-specific preference token. |
| `subjectIdentityValues` | Identity values of the current user, keyed by field ID. |
| `debug` | Enables debug logging. |
| `callbacks.onSuccess` | Called when preferences are saved. |
| `callbacks.onError` | Called with the error when something fails. |
| `callbacks.onClose` | Called when the user closes the screen. |

## Support

For help or to report an issue, contact [support@gotrust.tech](mailto:support@gotrust.tech) or visit [gotrust.tech](https://gotrust.tech).

## License

MIT

---

Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)

---
_Source: https://npm.io/package/@go-trust/mobile-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
