# Chargebee.js
Chargebee.js is the client-side JavaScript library that connects your application to Chargebee. Use it to open Chargebee-hosted checkout and self-serve portal pages, collect payment details securely, render pricing tables, and run in-app offers and cancel flows.
This site is the API reference for the library. For conceptual guides, configuration steps, and integration walkthroughs, see Chargebee product documentation (opens new window) and Chargebee tutorials (opens new window).
# Get started
Add the library to your page and initialize it once:
<script src="https://js.chargebee.com/v2/chargebee.js"></script>
1
const chargebee = Chargebee.init({
site: "YOUR-CHARGEBEE-BILLING-SUBDOMAIN"
});
1
2
3
2
3
See Set up Chargebee.js for the full setup, including custom domains and publishable keys.
# Tutorials
For step-by-step integration walkthroughs, see all Chargebee.js tutorials (opens new window).
# Reference
# Core
- Set up Chargebee.js — include and initialize the library.
- Chargebee library — the global
Chargebeeobject:init(),getInstance(),tearDown(). - Chargebee object — the initialized instance and every method it exposes.
# Checkout and portal
- Chargebee Portal object — open and control the self-serve portal.
- Cart object — build a cart and proceed to checkout.
- Product object — add plans, addons, and charges to a cart.
# Payments
- Payment Components — the current, recommended way to collect payment details.
- Payment handlers Deprecated — per-method handlers for cards, banks, wallets, and vouchers.
- Card Component and fields Deprecated — the hosted card fields.
# Growth and conversion
- Pricing table — render a configurable pricing page.
- Personalized offers — show relevant upgrade offers in your app.
- Cancel page — intercept cancel flows with alternative options.
# Utilities
- Functions — EU VAT validation and other utility calls.