# Installation

The Platform SDK can be installed using two primary methods: **CDN** and **NPM**.

- [NPM installation](#npm-installation)
- [CDN installation](#cdn-installation)


## NPM installation

Load the latest v2 via a package manager:

npm

```bash
npm install @transmitsecurity/platform-web-sdk@^2
```

yarn

```bash
yarn add @transmitsecurity/platform-web-sdk@^2
```

Depending on your tasks, import one or several modules, and then initialize them. Using individual module imports (e.g., `@transmitsecurity/platform-web-sdk/drs`) instead of the full SDK import helps reduce your bundle size. This dramatically improves page load times and user experience.

You can import and use the Platform SDK in different ways, depending on your needs:

- [Import specific functions from individual subpaths (recommended)](#import-specific-functions-from-individual-subpaths-recommended): Ideal when you need only a few SDK features. It includes only the functions you import, requires no initialization, and keeps the bundle small—great for faster load times and better performance on mobile or slow networks.
- [Import individual modules](#import-individual-modules): Best for most use cases. It supports tree-shaking to exclude unused modules and keeps overhead low, balancing flexibility and performance.
- [Import multiple modules](#import-multiple-modules): Use this if you need to configure modules separately or support legacy code. Tree-shaking is less effective, and some modules must be instantiated, which increases bundle size.


### Import specific functions from individual subpaths (recommended)

Use this approach when you only need a few specific SDK functions and want the smallest possible bundle.

Note
The functions shown are examples only. For the full list of functions in each module, see that module’s SDK reference.

Orchestration

```js
// Import Orchestration functions
import {
  startJourney,
  initialize,
} from '@transmitsecurity/platform-web-sdk/ido';

// Initialize SDK
initialize({
  clientId: 'your-client-id',
  ido: {
    serverPath: 'https://api.transmitsecurity.io/ido' // Required: Set serverPath based on your region or custom domain
  }
});

// Example usage after initialization
await startJourney('JOURNEY_ID');
```

Fraud Prevention

```js
// Import Fraud Prevention functions
import {
  triggerActionEvent,
  getSessionToken,
  initialize,
} from '@transmitsecurity/platform-web-sdk/drs';

// Initialize SDK
initialize({
  clientId: 'your-client-id',
  drs: {
    serverPath: 'https://api.transmitsecurity.io/risk-collect/', // Required: Set serverPath based on your region or custom domain
    enableSessionToken: true
  }
});

// Example usage after initialization
await triggerActionEvent('login', { correlationId: 'id', claimedUserId: 'claimed_user_id' });
const sessionToken = await getSessionToken();
```

Identity Verification

```js
// Import Identity Verification functions
import { start, recapture } from '@transmitsecurity/platform-web-sdk/idv';

// Import Fraud Prevention needed for Identity Verification
import * as drs from '@transmitsecurity/platform-web-sdk/drs';

// Import initialize from root
import { initialize } from '@transmitsecurity/platform-web-sdk';

// Initialize SDK
initialize({
  clientId: 'your-client-id',
  idv: {
    serverPath: 'https://api.transmitsecurity.io/verify' // Required: Set serverPath based on your region or custom domain
  },
  drs: {
    serverPath: 'https://api.transmitsecurity.io/risk-collect/', // Required: Set serverPath based on your region or custom domain
  }
});

// Example usage after initialization
await start(startToken);
```

WebAuthn

```js
// Import WebAuthn functions
import {
  authenticate,
  register,
  initialize,
} from '@transmitsecurity/platform-web-sdk/webauthn';

// Initialize SDK
initialize({
  clientId: 'your-client-id',
  webauthn: {
    serverPath: 'https://api.transmitsecurity.io' // Required: Set serverPath based on your region or custom domain
  }
});

// Example usage after initialization
await authenticate.modal('USERNAME');
```

Notes
The SDK modules can be configured to work with a different region by setting `serverPath` for each module individually. If you're using a [custom domain](/guides/deployment/custom_domains) for your application, replace the Transmit domain (`api.transmitsecurity.io`) with your custom domain in each `serverPath` (for example, `https://your-domain.com/ido` instead of `https://api.transmitsecurity.io/ido`). For the SDK to work properly, the regions must match.

### Import individual modules

Use this when you need an entire modules with minimal overhead. For example:

Orchestration

```js
// Import Orchestration module
import * as ido from '@transmitsecurity/platform-web-sdk/ido';

// Initialize SDK
ido.initialize({
  clientId: 'your-client-id',
  ido: {
    serverPath: 'https://api.transmitsecurity.io/ido' // Required: Set serverPath based on your region or custom domain
  }
});

// Example usage after initialization
await ido.startJourney('JOURNEY_ID');
```

Fraud Prevention

```js
// Import Fraud Prevention module
import * as drs from '@transmitsecurity/platform-web-sdk/drs';

// Initialize SDK
drs.initialize({
  clientId: 'your-client-id',
  drs: {
    serverPath: 'https://api.transmitsecurity.io/risk-collect/', // Required: Set serverPath based on your region or custom domain
    enableSessionToken: true
  }
});

// Example usage after initialization
await drs.triggerActionEvent('login', { correlationId: 'id', claimedUserId: 'claimed_user_id' });
const sessionToken = await drs.getSessionToken();
```

Identity Verification

```js
// Import Identity Verification module
import * as idv from '@transmitsecurity/platform-web-sdk/idv';
// Identity Verification module requires the Fraud Prevention module to be imported
import * as drs from '@transmitsecurity/platform-web-sdk/drs';
// Import initialize function from root
import { initialize } from '@transmitsecurity/platform-web-sdk';

// Initialize SDK
initialize({
  clientId: 'your-client-id',
  idv: {
    serverPath: 'https://api.transmitsecurity.io/verify' // Required: Set serverPath based on your region or custom domain
  },
  drs: {
    serverPath: 'https://api.transmitsecurity.io/risk-collect/', // Required: Set serverPath based on your region or custom domain
  }
});

// Example usage after initialization
await idv.start(startToken);
```

WebAuthn

```js
// Import WebAuthn module
import * as webauthn from '@transmitsecurity/platform-web-sdk/webauthn';

// Initialize SDK
webauthn.initialize({
  clientId: 'your-client-id',
  webauthn: {
    serverPath: 'https://api.transmitsecurity.io' // Required: Set serverPath based on your region or custom domain
  }
});

// Example usage after initialization
await webauthn.authenticate.modal('USERNAME');
```

Note
The SDK modules can be configured to work with a different region by setting `serverPath` for each module individually. If you're using a [custom domain](/guides/deployment/custom_domains) for your application, replace the default Transmit domain (`api.transmitsecurity.io`) with your custom domain in each `serverPath` (for example, `https://your-domain.com/ido` instead of `https://api.transmitsecurity.io/ido`). For the SDK to work properly, the regions must match.

### Import multiple modules

Use this when you want to use several modules or are maintaining existing code that uses class-based SDK instances. Tree-shaking removes any unused modules after a single `initialize()` call.


```js
// Import initialize function and modules from root
// Import only the modules you need
import { initialize, ido, drs, idv, webauthn } from '@transmitsecurity/platform-web-sdk';

// Initialize SDK
// Initialize only the modules you need
initialize({
  clientId: 'your-client-id',
  drs: {
    serverPath: 'https://api.transmitsecurity.io/risk-collect/' // Required: Set serverPath based on your region or custom domain
  },
  ido: {
    serverPath: 'https://api.transmitsecurity.io/ido' // Required: Set serverPath based on your region or custom domain
  },
  idv: {
    serverPath: 'https://api.transmitsecurity.io/verify' // Required: Set serverPath based on your region or custom domain
  },
  webauthn: {
    serverPath: 'https://api.transmitsecurity.io' // Required: Set serverPath based on your region or custom domain
  }
});

// Example usage after initialization
await ido.startJourney('JOURNEY_ID');
await drs.triggerActionEvent('login', { correlationId: 'id', claimedUserId: 'claimed_user_id' });
await idv.start(startToken);
await webauthn.authenticate.modal('USERNAME');
```

Notes
- When using multiple modules, always use a single `initialize` call.
- The SDK modules can be configured to work with a different region by setting `serverPath` for each module individually. If you're using a [custom domain](/guides/deployment/custom_domains) for your application, replace the Transmit domain (`api.transmitsecurity.io`) with your custom domain in each `serverPath` (for example, `https://your-domain.com/ido` instead of `https://api.transmitsecurity.io/ido`). For the SDK to work properly, the regions must match.


## CDN installation

CDN installation is recommended for rapid prototyping and testing. Load the SDK directly via CDN by adding the following HTML `<script>` tag in all relevant pages:


```html
<!-- Load the latest SDK -->
<script src="https://platform-websdk.transmitsecurity.io/platform-websdk/2.x/ts-platform-websdk.js" defer="true" id="ts-platform-script"></script>
```

Wait for the SDK to load before using it:


```js
document.getElementById('ts-platform-script').addEventListener('load', () => {
  // SDK is ready - initialize
  // Invoke functions inside 'window.tsPlatform'
  window.tsPlatform.initialize({
    clientId: 'your-client-id',
    drs: {
      serverPath: 'https://api.transmitsecurity.io/risk-collect/' // Required: Set serverPath based on your region or custom domain
    },
    ido: {
      serverPath: 'https://api.transmitsecurity.io/ido' // Required: Set serverPath based on your region or custom domain
    },
    idv: {
      serverPath: 'https://api.transmitsecurity.io/verify' // Required: Set serverPath based on your region or custom domain
    },
    webauthn: {
      serverPath: 'https://api.transmitsecurity.io' // Required: Set serverPath based on your region or custom domain
    }
  });
});
```

Note
The SDK modules can be configured to work with a different region or a [custom domain](/guides/deployment/custom_domains) by setting `serverPath` for each module individually. For the SDK to work properly, the regions must match.

style

    section article ul li {
        margin-top: 3px !important;
    }