Frontend Blocks typescript Intermediate

Stripe.js Payment Element

Render a Stripe Payment Element in React and confirm the payment on submit.

typescript
import { useStripe, useElements, PaymentElement } from "@stripe/react-stripe-js";

export function CheckoutForm({ clientSecret }: { clientSecret: string }) {
  const stripe   = useStripe();
  const elements = useElements();

  const submit = async (e: React.FormEvent) => {
    e.preventDefault();
    if (!stripe || !elements) return;
    const { error } = await stripe.confirmPayment({
      elements,
      confirmParams: { return_url: window.location.origin + "/thanks" },
    });
    if (error) console.error(error.message);
  };
  return (
    <form onSubmit={submit}>
      <PaymentElement />
      <button type="submit">Pay</button>
    </form>
  );
}

Prerequisites

  • @stripe/react-stripe-js >= 2
  • @stripe/stripe-js

Pro Tips

  • → Wrap the form in <Elements stripe={stripePromise} options={{clientSecret}}>.

Was this module useful?

Share your experience — it helps the team improve.

Leave Feedback

Commercial Licensing

Acquire a production access token or template license for enterprise deployment.

Module Info

Language
typescript
Level
Intermediate
Read time
4 min
Published
Apr 2026
License
Commercial License

Newsletter

New modules every week, directly to your inbox.