Paddle Billing
Search

Include and initialize Paddle.js

Include Paddle.js on your website to start building checkout experiences with Paddle. Initialize by passing a client-side token and Retain API key.

To start building subscription billing experiences with Paddle, include Paddle.js on your checkout pages and in-app.

Import as a module with TypeScript definitions

You can install Paddle.js using a JavaScript package manager, then import and initialize.

The Paddle.js module includes TypeScript definitions for Paddle.js methods, so you can use type checking to write more robust code.

To install using npm:

To install using yarn:

Use the initializePaddle method to initialize Paddle.js. See: Paddle.js wrapper on GitHub

Manually load the Paddle.js script

You can manually load the Paddle.js script by adding a link to Paddle.js in the <head> of pages where you use Paddle Checkout or Paddle Retain:

Always load Paddle.js directly from https://cdn.paddle.com/. This makes sure that you're running with the latest security and feature updates from Paddle.

Initialize Paddle.js

Call the Paddle.Setup() method and pass token to initialize.

tokenstring

Client-side token for authentication. You can create and manage client-side tokens in Paddle > Developer tools > Authentication. Required.

To create and manage client-side tokens, go to Paddle > Developer tools > Authentication. Click Generate client-side token under the "Client-side tokens" section.

Do not use API keys when working with Paddle.js. API keys must be kept secret.

Initialize Paddle.js and Retain

Paddle.js integrates with Retain, so you don't have to include a separate Retain script in your app or website. Client-side tokens for live accounts authenticate with both Paddle Billing and Paddle Retain, so there's no need to pass a separate key for Retain.

To use Retain, include Paddle.js on every page of your web app or website — including your commercial or marketing website.

Call the Paddle.Setup() method and pass token and pwCustomer where:

tokenstring

Client-side token for authentication. You can create and manage client-side tokens in Paddle > Developer tools > Authentication. Required.

pwCustomerobject or null

Identifier for a logged-in customer for Retain Notifications. Pass either id or email, or an empty object if you don't have a logged-in customer.

idstring or null

Paddle ID for a customer entity in Paddle. Do not pass a subscription ID.

emailstring<email> or null

Email address related to a customer entity in Paddle.

Related pages