Skip to content

Type updates to fix reduced actions in form sdk#672

Merged
alic-stripe merged 3 commits intostripe:masterfrom
ashkan-stripe:ashkan/form-sdk-actions-update
Apr 27, 2026
Merged

Type updates to fix reduced actions in form sdk#672
alic-stripe merged 3 commits intostripe:masterfrom
ashkan-stripe:ashkan/form-sdk-actions-update

Conversation

@ashkan-stripe
Copy link
Copy Markdown
Contributor

@ashkan-stripe ashkan-stripe commented Apr 24, 2026

Summary & motivation

stripe-js v9.3.1 removed 5 action methods from initCheckoutFormSdk() (the Form SDK now exposes 7 actions instead of 12). This PR updates react-stripe-js to reflect that.

What changed

  • Added two new hooks:
    • useCheckoutElements() for use inside <CheckoutElementsProvider>. Returns the full 12-action surface.
    • useCheckoutForm() for use inside <CheckoutFormProvider>. Returns the narrower 7-action surface, so calling one of the removed methods is now a compile-time error.
    • Both throw a clear runtime error if used under the wrong provider.
  • Deprecated useCheckout() via JSDoc. It still works and points users at the new hooks. It now aliases useCheckoutElements() so behavior is consistent.
  • Bumped the @stripe/stripe-js peer dependency floor to >=9.3.1 <10.0.0 since we now reference types introduced in 9.3.1.

What does not change

  • Existing <CheckoutElementsProvider> + useCheckout() integrations keep working exactly as they do today. No code changes required for Elements consumers.

API review

Copy this template or link to an API review issue.

Testing & documentation

});
});

// Mirrors the pay-server runtime transform that strips 5 client-only
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be referencing 'pay-server` in OSS?

@rvolyar-stripe
Copy link
Copy Markdown
Contributor

@ashkan-stripe can we pls beef up the PR description now/later to be more descriptive?

Copy link
Copy Markdown
Contributor

@rvolyar-stripe rvolyar-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashkan-stripe left two comments/questions


const CheckoutFormExample = ({layout}) => {
const checkoutState = useCheckout();
const checkoutState = useCheckoutForm();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to also update examples/hooks/11-Custom-Checkout.js to reference useCheckoutElements()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! updated ✅

};

/**
* @deprecated Prefer the provider-specific hooks:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as a consumer, it would be nice to see:

  • since what version is this deprecated
  • when will it be removed
  • what is the alternative ✅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion, updated ✅

@alic-stripe alic-stripe merged commit ac7043b into stripe:master Apr 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants