---
title: "PayPal · Nuxt Scripts"
description: "Load PayPal's JavaScript SDK v6 and create checkout or messaging sessions from Vue components."
canonical_url: "https://scripts.nuxt.com/scripts/paypal"
meta:
  "og:description": "Load PayPal's JavaScript SDK v6 and create checkout or messaging sessions from Vue components."
  "og:image": "https://scripts.nuxt.com/_og/s/o_0b6ef1b6bee2aa74.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "PayPal · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_0b6ef1b6bee2aa74.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Scripts**

# **PayPal**

[Copy for LLMs](https://scripts.nuxt.com/scripts/paypal.md)

[**PayPal**](https://www.paypal.com) provides online checkout and payment APIs.

Nuxt Scripts integrates the [**PayPal JavaScript SDK v6**](https://developer.paypal.com/sdk/js/reference) through:

- `**useScriptPayPal**` composable, which loads `**https://www.paypal.com/web-sdk/v6/core**`.
- `**ScriptPayPalButtons**` component that initializes the PayPal SDK v6 instance and exposes it via a scoped slot.
- `**ScriptPayPalMessages**` component for creating a `**paypal-messages**` session.

**PayPal**

[**View source **](https://github.com/nuxt/scripts/blob/main/packages/script/src/runtime/registry/paypal.ts)

## Nuxt Config Setup

Add this to your `**nuxt.config.ts**` to load PayPal globally. Alternatively you can use the **useScriptPayPal** composable for more control.

```
export default defineNuxtConfig({
  scripts: {
    registry: {
      paypal: {
        trigger: 'onNuxtReady',
      }
    }
  }
})
```

## useScriptPayPal()

The `**useScriptPayPal**` composable lets you have fine-grain control over when and how PayPal is loaded on your site.

```
const { proxy } = useScriptPayPal()

// PayPal buttons render via component
```

Please follow the [**Registry Scripts **](https://scripts.nuxt.com/docs/guides/registry-scripts) guide to learn more about advanced usage.

## Example

Using PayPal in a component.

ConversionButton.vue

```
<script setup lang="ts">
const { proxy } = useScriptPayPal()

// noop in development, ssr
// just works in production, client
function handleAction() {
  // PayPal buttons render via component
}
</script>

<template>
  <div>
    <button @click="handleAction">
      Send Event
    </button>
  </div>
</template>
```

The `**trigger**` prop on `**ScriptPayPalButtons**` and `**ScriptPayPalMessages**` currently has no effect on SDK loading or facade state. Configure `**scripts.registry.paypal.trigger**` when you need to defer the SDK itself.

The composable uses PayPal's sandbox endpoint in development and the live endpoint in production unless you set `**sandbox**` explicitly.

## Types

Install `**@paypal/paypal-js**` for full TypeScript support.

```bash
pnpm add -D @paypal/paypal-js
```

Nuxt Scripts requires `**@paypal/paypal-js**` v11 or later. The v6 SDK types are available from `**@paypal/paypal-js/sdk-v6**`.

### Demo

placeholder

placeholder

#### **With environment variables**

Configure the client ID with an environment variable:

nuxt.config.ts

```ts
export default defineNuxtConfig({
  scripts: {
    registry: {
      paypal: { trigger: 'onNuxtReady' },
    }
  },
})
```

The module automatically registers PayPal's public `**clientId**` runtime-config field, so you can omit a manual `**runtimeConfig**` block.

.env

```text
NUXT_PUBLIC_SCRIPTS_PAYPAL_CLIENT_ID=<YOUR_CLIENT_ID>
```

The facade components currently default their `**client-id**` prop to the literal value `**test**`. That prop overrides runtime config, so pass the resolved ID to the component explicitly:

```vue
<script setup lang="ts">
const config = useRuntimeConfig()
const clientId = config.public.scripts.paypal.clientId
</script>

<template>
  <ScriptPayPalButtons :client-id="clientId" />
</template>
```

Without that prop, a production build uses PayPal's live endpoint with the `**test**` client ID.

### Composable

```ts
export function useScriptPayPal<T extends PayPalApi>(_options?: PayPalInput) {}
```

For triggers, proxying, and other script options, see [**Registry Scripts**](https://scripts.nuxt.com/docs/guides/registry-scripts).

```
export const PayPalOptions = union([
  object({
    /**
     * Your PayPal client ID.
     * @see https://developer.paypal.com/sdk/js/reference/
     */
    clientId: string(),
    clientToken: optional(string()),
    /**
     * Use the PayPal sandbox environment. Defaults to `true` in development.
     */
    sandbox: optional(boolean()),
  }),
  object({
    clientId: optional(string()),
    /**
     * A server-generated client token for authentication.
     * @see https://docs.paypal.ai/payments/methods/paypal/sdk/js/v6/paypal-checkout
     */
    clientToken: string(),
    /**
     * Use the PayPal sandbox environment. Defaults to `true` in development.
     */
    sandbox: optional(boolean()),
  }),
])
```

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/paypal.md)

[Markdown For LLMs](https://scripts.nuxt.com/scripts/paypal.md)

[**NPM** Load IIFE scripts from NPM in your Nuxt app.](https://scripts.nuxt.com/scripts/npm) [**Plausible Analytics** Load Plausible's site-specific tracker, including custom self-hosted endpoints.](https://scripts.nuxt.com/scripts/plausible-analytics)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","description":"Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/scripts/paypal#webpage","@type":"WebPage","description":"Load PayPal's JavaScript SDK v6 and create checkout or messaging sessions from Vue components.","name":"PayPal","url":"https://scripts.nuxt.com/scripts/paypal","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/paypal#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/paypal"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/scripts/paypal#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Scripts","item":"https://scripts.nuxt.com/scripts","position":2},{"@type":"ListItem","name":"PayPal","item":"https://scripts.nuxt.com/scripts/paypal","position":3}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
