The Paddle.js wrapper (@paddle/paddle-js) is a typed ES-module wrapper around Paddle.js. Install it using a JavaScript package manager and import initializePaddle directly, with full TypeScript definitions for every method.
Use the wrapper when you're working in a bundled JavaScript or TypeScript project, like Next.js, Remix, Astro, Vite, or similar. If you're loading Paddle.js from a <script> tag instead, see Include and initialize Paddle.js.
Install
pnpm add @paddle/paddle-jsyarn add @paddle/paddle-jsnpm install @paddle/paddle-jsInitialize
Import initializePaddle and call it with a client-side token. Client-side tokens are created in Paddle > Developer tools > Authentication. Sandbox tokens are prefixed with test_.
import { initializePaddle, type Paddle } from '@paddle/paddle-js';
const paddle: Paddle | undefined = await initializePaddle({ environment: 'sandbox', token: process.env.NEXT_PUBLIC_PADDLE_CLIENT_TOKEN!,});Drop environment, or set it to production, for live accounts.
Full usage
The wrapper exposes the same API as Paddle.js itself. For full documentation of every method and event, see:
- Include and initialize Paddle.js: full setup including Retain.
- Paddle.js methods: every method the wrapper exposes.
- Paddle.js events: every event you can listen for.