Scripts

PayPal is a popular payment gateway that allows you to accept payments online.

Nuxt Scripts provides multiple PayPal features:

  • useScriptPayPal composable which loads the script https://www.paypal.com/sdk/js.
  • ScriptPayPalButtons component that allows you to embed PayPal Buttons on your site.
  • ScriptPayPalMarks component that allows you to embed PayPal Marks on your site.
  • ScriptPayPalMessages component that allows you to embed PayPal Messages on your site.

Script Stats

Loading
NPM
First-Party
No
Bundling
No
Tracked Data
Transactions

Types

To use the PayPal with full TypeScript support, you will need to install the @paypal/paypal-js dependency.

pnpm add -D @paypal/paypal-js

Demo

placeholder
placeholder
placeholder

With Environment Variables

If you prefer to configure your client ID using environment variables.

nuxt.config.ts
export default defineNuxtConfig({
  scripts: {
    registry: {
      paypal: true,
    }
  },
  // you need to provide a runtime config to access the environment variables
  runtimeConfig: {
    public: {
      scripts: {
        paypal: {
          clientId: '', // NUXT_PUBLIC_SCRIPTS_PAYPAL_CLIENT_ID
        },
      },
    },
  },
})
.env
NUXT_PUBLIC_SCRIPTS_PAYPAL_CLIENT_ID=<YOUR_CLIENT_ID>