Skip to main content

Migration Guide

This guide covers migrating from MONEI Components v2 to v3. If you're starting fresh, see the Components overview or go directly to your framework page.

What's new in v3

  • Dedicated framework packages@monei-js/react-components, @monei-js/vue-components, @monei-js/angular-components, @monei-js/svelte-components
  • submit() API — call submit() directly on the component instance instead of createToken()
  • Typed props — full TypeScript support for all component props and events
  • Svelte 5 support — new @monei-js/svelte-components package
  • Payment Modal — call confirmPayment() without a token to open a full checkout modal

CDN URL change

- <script src="https://js.monei.com/v2/monei.js"></script>
+ <script src="https://js.monei.com/v3/monei.js"></script>

npm package change

- npm install @monei-js/components@1.x
+ npm install @monei-js/components@2.x

Framework import changes

The .driver() API is replaced by dedicated framework packages. Each package exports native components — no more wrapping or bridging.

No import changes — vanilla JS uses @monei-js/components in both v2 and v3.

import {CardInput} from '@monei-js/components';

const cardInput = CardInput({paymentId: '...'});
cardInput.render('#card-input');

createToken()submit() migration

The standalone createToken(instance) function is replaced by instance.submit(). The return type is the same: {token?: string, error?: string}.

Before:

import {CardInput, createToken} from '@monei-js/components';

const cardInput = CardInput({paymentId: '...'});
cardInput.render('#card-input');
const {token} = await createToken(cardInput);

After:

import {CardInput} from '@monei-js/components';

const cardInput = CardInput({paymentId: '...'});
cardInput.render('#card-input');
const {token} = await cardInput.submit({cardholderName: 'John'});

What's NOT changed

note

monei.api.createToken() (used in Apple Pay and Google Pay for wallet token exchange) is a different API and is not deprecated. Only the component-level createToken(instance) is deprecated.

Deprecated APIs

The following APIs still work in v3 but log deprecation warnings in the console:

DeprecatedReplacement
.driver('react', {React})import from '@monei-js/react-components'
.driver('vue3')import from '@monei-js/vue-components'
.driver('angular', {...})import from '@monei-js/angular-components'
createToken(instance)instance.submit()

These deprecated APIs will be removed in a future major version.