Overview
The elements.update() method in Stripe.js now returns a Promise when the update has been applied to all rendered Elements. This brings the method in line with other async Elements methods like elements.submit() and elements.fetchUpdates(), providing a more consistent developer experience.
Breaking Change
The return type has changed from void to Promise. This means:
- TypeScript integrations that explicitly type the return value need to update their type annotations from
voidtoPromise - Code that expects
elements.update()to return nothing may need updates - The existing
update-endevent listener remains available for backward compatibility
What Developers Can Do
You can now use modern async/await patterns instead of event listeners:
Before (event-based pattern):
elements.update({locale: 'fr'});
elements.on('update-end', () => {
// Update is complete
});
After (async/await pattern):
await elements.update({locale: 'fr'});
// Update is complete
The event listener approach continues to work, so migration is not strictly required. However, if you use TypeScript and explicitly type the return value as void, you must update that type annotation to Promise.
Related Updates
This change is part of a broader set of updates to Stripe Elements, including changes to Address Element formatting, Payment Element configuration, and removal of deprecated methods from Stripe.js.