# 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](https://www.chargebee.com/docs/) and [Chargebee tutorials](https://www.chargebee.com/tutorials/topics/chargebee-js/).

## Get started

Add the library to your page and initialize it once:

```html
<script src="https://js.chargebee.com/v2/chargebee.js"></script>
```

```js
const chargebee = Chargebee.init({
  site: "YOUR-CHARGEBEE-BILLING-SUBDOMAIN"
});
```

See [Set up Chargebee.js](https://www.chargebee.com/docs/js/settingup-api-ref) for the full setup, including custom domains and publishable keys.

## Tutorials

For step-by-step integration walkthroughs, see [all Chargebee.js tutorials](https://www.chargebee.com/tutorials/topics/chargebee-js/).

## Reference

### Core

- [Set up Chargebee.js](https://www.chargebee.com/docs/js/settingup-api-ref) - include and initialize the library.
- [Chargebee library](https://www.chargebee.com/docs/js/cb-library-api-ref) - the global `Chargebee` object: `init()`, `getInstance()`, `tearDown()`.
- [Chargebee object](https://www.chargebee.com/docs/js/cbinstanceobj-api-ref) - the initialized instance and every method it exposes.

### Checkout and portal

- [Chargebee Portal object](https://www.chargebee.com/docs/js/cbportal-api-ref) - open and control the self-serve portal.
- [Cart object](https://www.chargebee.com/docs/js/cart-api-ref) - build a cart and proceed to checkout.
- [Product object](https://www.chargebee.com/docs/js/product-api-ref) - add plans, addons, and charges to a cart.

### Payments

- [Payment Components](https://www.chargebee.com/docs/js/payment-components-api-ref) - the current, recommended way to collect payment details.
- [Payment handlers](https://www.chargebee.com/docs/js/payment-handler-api-ref) Deprecated - per-method handlers for cards, banks, wallets, and vouchers.
- [Card Component and fields](https://www.chargebee.com/docs/js/component-field-api-ref) Deprecated - the hosted card fields.

### Growth and conversion

- [Pricing table](https://www.chargebee.com/docs/js/pricing-table-api-ref) - render a configurable pricing page.
- [Personalized offers](https://www.chargebee.com/docs/js/personalized-offers-api-ref) - show relevant upgrade offers in your app.
- [Cancel page](https://www.chargebee.com/docs/js/cancel-page-api-ref) - intercept cancel flows with alternative options.

### Utilities

- [Functions](https://www.chargebee.com/docs/js/functions-api-ref) - EU VAT validation and other utility calls.
