Troubleshooting Web Elements
This guide covers issues specific to v3. For v2, see the v2 Troubleshooting guide.
Need help? Email support@basistheory.com with your package version, browser, framework, and a reproduction.
v3-Specific Gotchas
Initialization is synchronous
v3 init is synchronous — do not await it.
// WRONG — await returns undefined
const bt = await BasisTheory('<PUBLIC_API_KEY>');
// CORRECT
const bt = BasisTheory('<PUBLIC_API_KEY>');
Elements load lazily when first mounted. The bt instance is immediately usable.
CDN global name changed
The CDN global in v3 is BasisTheory (capitalized), not basistheory.
<script>
document.addEventListener('DOMContentLoaded', () => {
const bt = BasisTheory('<PUBLIC_API_KEY>'); // uppercase B and T
});
</script>
Element type names changed
v3 uses different element type strings:
| v2 | v3 |
|---|---|
'card' | Removed — use separate 'cardNumber', 'expiry', 'cvv' elements |
'cardExpirationDate' | 'expiry' |
'cardVerificationCode' | 'cvv' |
'text' | 'text' (unchanged) |
// WRONG (v2 types)
bt.createElement('card', { targetId: 'card' });
bt.createElement('cardExpirationDate', { targetId: 'expiry' });
// CORRECT (v3 types)
bt.createElement('cardNumber');
bt.createElement('expiry');
bt.createElement('cvv');
Change event payload changed
The change event in v3 uses event.detail, not direct properties on the event object.
// WRONG (v2 shape)
element.on('change', (event) => {
if (event.complete) { ... }
if (event.error) { ... }
});
// CORRECT (v3 shape)
element.on('change', (event) => {
if (event.detail.isValid) { ... }
if (event.detail.error) { ... }
if (event.detail.isEmpty) { ... }
});
on() returns an unsubscribe function
In v3, element.on() returns () => void — call it to stop listening. It no longer returns a Subscription object.
const unsubscribe = cardNumberEl.on('change', handler);
// Later, to remove the listener:
unsubscribe();