Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

react-stripe-js

> 编程语言
Open source

React components for Stripe.js and Stripe Elements

2.0K stars0 likes3 views
WebsiteGitHub

About

React components for Stripe.js and Stripe Elements

React Stripe.js

React components for Stripe.js and Elements.

Requirements

The minimum supported version of React is v16.8. If you use an older version, upgrade React to use this library. If you prefer not to upgrade your React version, we recommend using legacy react-stripe-elements.

Getting started

  • Build a custom checkout page using the Checkout Sessions API
  • Add React Stripe.js to your React app
  • Try it out using CodeSandbox

Documentation

  • React Stripe.js reference
  • Migrate from react-stripe-elements
  • Legacy react-stripe-elements docs
  • Examples

Build a custom checkout page

For a new custom checkout page, we recommend the Checkout Sessions API with ui_mode: 'elements'. This lets you combine Stripe Elements with your own React layout while Checkout Sessions manages the checkout state. If you want to own every part of your checkout, the lower-level Payment Intents API provides more fine-grained control, but requires significantly more code and ongoing maintenance.

First, install React Stripe.js and Stripe.js.

bash
npm install @stripe/react-stripe-js @stripe/stripe-js

Create a Checkout Session on your server using trusted product and pricing data, then return its client secret:

javascript
// POST /create-checkout-session
const session = await stripe.checkout.sessions.create({
  ui_mode: 'elements',
  mode: 'payment',
  return_url: 'https://example.com/order/123/complete',
  line_items: [
    {
      price_data: {
        currency: 'usd',
        product_data: {name: 'T-shirt'},
        unit_amount: 1099,
      },
      quantity: 1,
    },
  ],
});

if (!session.client_secret) {
  throw new Error('Checkout Session is missing a client secret.');
}

res.json({clientSecret: session.client_secret});

Client:

…

TypeScript support

React Stripe.js is packaged with TypeScript declarations. Some types are pulled from @stripe/stripe-js—be sure to add @stripe/stripe-js as a dependency to your project for full TypeScript support.

Typings in React Stripe.js follow the same versioning policy as @stripe/stripe-js.

Contributing

This project is maintained by Stripe and does not accept external pull requests. If you have feedback or ideas, please open an issue.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言