---
Source: https://docs.microblink.com/platform/sdk/web/migrate-v2
Title: Migrate to v2
Description: Migrate your Microblink Platform Web SDK integration from v1 to v2
---

# Migrate to v2

This guide lists the changes you need to make in your web app to move from v1 to v2 of the Web SDK.

The SDK no longer creates transactions: your backend does, and passes the result to your app.
Before you update the SDK, update your backend as described in the [Platform migration guide](../../migrate-v2.md), in particular [No proxy](../../migrate-v2.md#no-proxy) and [Consent](../../migrate-v2.md#consent).

## Installation, imports, dependencies

### Package installation

The package name is unchanged: **@microblink/platform-sdk**, and you can still get it [from NPM](https://www.npmjs.com/package/@microblink/platform-sdk).
Update it to v2:

```bash
npm install @microblink/platform-sdk@2
```

### Changed import statements

```js title="Vanilla JS"
// v1

// v2

// note: no more "vanilla" in import statement
```

```js title="React"
// v1

// v2

```

### Fewer dependencies

In v1, the SDK required `react`, `react-dom`, and `styled-components` as peer dependencies, even if you integrated with vanilla JS.
In v2, it has no required peer dependencies; you only need `react` (version 18 or later) if you use the React entry point, and `vite` (version 5 or later) if you use the Vite plugin.
If you integrate with vanilla JS, you can remove `react`, `react-dom`, and `styled-components` from your dependencies, unless your app needs them for other reasons.

## Starting a verification

In v1, the SDK created the transaction itself: you gave it a proxy URL, a workflow ID, and the end user's consent.
In v2, your backend creates the transaction and gets back `sdkConfiguration`.
You pass that value to the SDK as `sessionToken`, and that's the only required configuration field.

<Tabs groupId="sdk-version">
<TabItem value="v1" label="v1">

```js title="Vanilla JS"
createIdvFlow({
  apiConfig: {
    proxy: { baseUrl: 'https://your.proxy.server' },
    workflowId: 'ID of the workflow to use',
  },
  consentData: {
    userId: 'unique user ID',
    isProcessingStoringAllowed: true,
  },
  onTransactionFinished: (result) => {
    console.log(result.transactionId, result.status);
  },
  onAbort: () => {
    console.log('User aborted the flow');
  },
  target: document.getElementById('idv-flow-div'),
});
```

</TabItem>
<TabItem value="v2" label="v2" default>

```js title="Vanilla JS"
// Your own endpoint that calls POST /api/v2/transaction and returns sdkConfiguration.
const response = await fetch('/start-verification', { method: 'POST' });
const { sdkConfiguration } = await response.json();

const sdk = createPlatformSdk({
  sessionToken: sdkConfiguration,
  target: document.getElementById('idv-flow-div'),
});

sdk.onTransactionEnd((result) => {
  console.log(result.transactionId, result.verificationStatus);
});

sdk.onAbort((info) => {
  console.log('User aborted the flow on step', info.step);
});
```

</TabItem>
</Tabs>

In React, the `IdvFlow` component is replaced by the `usePlatformSdk` hook, which owns the session, and the `PlatformFlowUI` component, which renders our screens:

<Tabs groupId="sdk-version">
<TabItem value="v1" label="v1">

```jsx title="React"
function Verification() {
  return (
    <IdvFlow
      apiConfig={{
        proxy: { baseUrl: 'https://your.proxy.server' },
        workflowId: 'ID of the workflow to use',
      }}
      consentData={{ userId: 'unique user ID', isProcessingStoringAllowed: true }}
      onTransactionFinished={(result) => console.log(result.status)}
    />
  );
}
```

</TabItem>
<TabItem value="v2" label="v2" default>

```jsx title="React"
// sessionToken is the sdkConfiguration your backend returned.
function Verification({ sessionToken }) {
  const sdk = usePlatformSdk({ sessionToken });

  useEffect(() => {
    if (sdk.currentStep === 'END' && sdk.state.verificationStatus) {
      console.log(sdk.state.transactionId, sdk.state.verificationStatus);
    }
  }, [sdk.currentStep, sdk.state.verificationStatus]);

  return <PlatformFlowUI config={sdk} />;
}
```

</TabItem>
</Tabs>

You pass your configuration to `usePlatformSdk`, and place `PlatformFlowUI` where the flow should appear.
The hook reads its configuration only once, so render this component after you have the session token.
React has no result callbacks; read the outcome from `sdk.state` instead.


## Configuration fields

The v2 configuration object has only these fields: `sessionToken`, `runAddress`, `target`, `translations`, `theme`, and `resourcesPath`.
The same object is used by `createPlatformSdk` and `usePlatformSdk`.

<Tabs groupId="sdk-version">
<TabItem value="v1" label="v1">

```js title="v1 configuration object"
{
  apiConfig: {
    proxy: { baseUrl: '...' },
    workflowId: '...',
    formValues: {},
    d2d: { runAddress: '...' },
  },
  consentData: {},
  mode: 'classic',
  enableD2D: false,
  scanTimeout: 60000,
  target: element,
  resourcesPath: '/resources',
  themeOverride: {},
  translationsOverride: {},
  startScreen: () => {},
  progressScreen: () => {},
  endResultScreen: () => {},
  onTransactionFinished: () => {},
  onAbort: () => {},
  onError: () => {},
  onExit: () => {},
  onCardScanResult: () => {},
}
```

</TabItem>
<TabItem value="v2" label="v2" default>

```js title="v2 configuration object"
{
  sessionToken: '...',
  runAddress: '...',
  target: element,
  resourcesPath: '/',
  theme: {},
  translations: {},
}
```

</TabItem>
</Tabs>

Here's what happened to v1 fields.

### D2D, consent, and other configuration

- `apiConfig` is replaced by `sessionToken`.
  v1 had two formats (one for new transactions, one for resuming existing ones); v2 has only one, because your backend always creates the transaction first.
- `consentData` is removed.
  The SDK no longer asks for consent: collect it in your app before the verification starts, and your backend sends it when it creates the transaction.
- `mode` and `enableD2D` are removed.
  Device-to-device flows are configured in the Platform UI for the workflow, and this information comes to the SDK in the session token.
- Related to the above, `apiConfig.d2d.runAddress` moves to the top-level `runAddress` field.
  Set it **only** if you host the [D2D](../../d2d.md) phone app yourself; if you omit it, and device-to-device is enabled for the transaction, the join link points to the Microblink-hosted page.

### Visuals and translations

- `themeOverride` is renamed to `theme`, and has internal changes.
- `translationsOverride` is renamed to `translations`, and has internal changes.

### Callbacks

- `onTransactionFinished`, `onAbort`, and `onError` are no longer configuration fields.
  Instead, you subscribe to them on the SDK instance with `sdk.onTransactionEnd()`, `sdk.onAbort()`, and `sdk.onError()`.
  The result's `status` is renamed to `verificationStatus`.
- `onExit`, already deprecated in v1, is removed.
- `startScreen`, `progressScreen`, and `endResultScreen` are removed.
  You can now replace the screen for most steps, such as `PROGRESS_OVERVIEW` and `END`, with `sdk.onStep()` (vanilla JS), or by checking `sdk.currentStep` before rendering `PlatformFlowUI` (React).
  `startScreen` has no replacement, because v2 has no start screen.
  Camera steps can't be replaced.
- `onCardScanResult` and `scanTimeout` are removed.

### Positioning and resources

- `target` is unchanged.
  If you don't set it, the SDK renders in a full-screen overlay.
- `resourcesPath` works as before, but its default has changed; see [Serve WASM resources](#serve-wasm-resources).

## Serve WASM resources

The camera steps still need their WebAssembly (WASM) and worker files served as static files, in a `resources` folder.

In v1, you copied the files from `node_modules/@microblink/platform-sdk/dist/resources`.
In v2, they come from the packages of the individual scanning SDKs, so instead of copying them by hand, use the `platform-web-sdk copy-resources` command that comes with the SDK.
Run it as part of your build, with your public output directory as the argument; it creates the `resources` folder inside it:

```json title="package.json"
{
  "scripts": {
    "prebuild": "platform-web-sdk copy-resources public"
  }
}
```

The files take about 130 MB in total.
If your workflows don't use all camera steps, copy only the ones they use with `--only`, for example `--only document,face`:

- `document`: document scanning and document verification, about 95 MB
- `card`: card scanning, about 30 MB
- `face`: face capture, about 5 MB

If a step's files are missing, that step fails when it starts the camera.

If you use Vite, you can use the SDK's plugin instead.
It copies all files into `public/resources` on every dev and build run:

```ts title="vite.config.ts"



  plugins: [...scanResourcesPlugin()],
});
```

`resourcesPath` works as before, but its default has changed.
In v1, the SDK loaded the files from `/resources/` at the root of your site; in v2, it loads them from a `resources/` folder next to the current page.
For a page at `https://example.com/app/verify`, that's `https://example.com/app/resources/`.
If you didn't set `resourcesPath` and your page isn't at the root of your site, set `resourcesPath: '/'` to keep loading the files from `/resources/`.

The files change with each SDK release.
Unless their path contains the SDK version, cache them with revalidation (for example, with `ETag`) rather than as immutable.

## Use a CDN

To serve the files from a CDN, upload the `resources` folder as it is, and set `resourcesPath` to the URL of the folder that contains it.
For example, if the files are in `https://cdn.example.com/sdk/resources/`, set `resourcesPath: 'https://cdn.example.com/sdk/'`.
The trailing slash is optional: `https://cdn.example.com/sdk` loads from the same place.


Last updated on Nov 26, 2026
