DEV Community


Discussion on: PayPal integration in React

uzomezu profile image
Kevin Mezu

You can simply install the react paypal elements instead of creating your own button. This allows you to call the functions createOrder, onApprove, and onError directly from the react element

Simply install:

npm install @paypal/react-paypal-js

Then import the elements into your client side:

import { PayPalScriptProvider, PayPalButtons } from "@paypal/react-paypal-js";

and then you would just return the following instead of creating your own react element:

export default function App() {
return (


Hope this helps, I find that the modern react syntax is much easier when you leverage any of the components available from npm/npx, simplify your code by increasing your dependencies.

uzomezu profile image