React components for the PayPal JS SDK.
https://paypal.github.io/react-paypal-js/
To get started, install react-paypal-js with npm.
npm install @paypal/react-paypal-js
This PayPal React library consists of two main parts:
- Context Provider - this
<PayPalScriptProvider />
component manages loading the JS SDK script. Add it to the root of your React app. It uses the Context API for managing state and communicating to child components. It also supports reloading the script when parameters change. - SDK Components - components like
<PayPalButtons />
are used to render the UI for PayPal products served by the JS SDK.
// App.js
import { PayPalScriptProvider, PayPalButtons } from "@paypal/react-paypal-js";
export default function App() {
return (
<PayPalScriptProvider options={{ "client-id": "sb" }}>
<PayPalButtons style={{ layout: "horizontal" }} />
</PayPalScriptProvider>
);
}
This library supports all popular browsers, including IE 11. It provides the same browser support as the JS SDK. Here's the full list of supported browsers.