# Installation

### From NPM

Tebex.js is available as an NPM package, which you can install using your preferred JS package manager:

```bash
npm install @tebexio/tebex.js
```

The **`Tebex`** object can then be imported into your code like so:

```javascript
import Tebex from "@tebexio/tebex.js";
```

### From Our CDN

Alternatively, we also provide Tebex.js via our own CDN, which you can add as a script within the `<head>` tag of your website:

```html
<script defer src="https://js.tebex.io/v/1.js"></script>
```

{% hint style="info" %}
We will automatically update `v/1.js` with new minor and patch releases of Tebex.js. This shouldn't present any breaking changes, but if you would prefer to stay on a fixed version, you can specify the full version number in the URL, for example `https://js.tebex.io/v/1.1.1.js`. Our version history can be found on our [GitHub](https://github.com/tebexio/Tebex.js/releases) releases page.
{% endhint %}

When installing Tebex.js this way, the **`Tebex`** object will become available globally on the `window` object.

We recommend using `defer` on the script to prevent it from blocking your website's initial page render, but when doing do, it's important to **wait for the page `load` event** before you begin configuring the checkout or payment portal:

```html
<script>
    addEventListener("load", function() {
        // Configure Tebex.js here
    });
</script>
```

### Next Steps

The **`Tebex`** object provides the following APIs:

* [`Tebex.checkout`](https://docs.tebex.io/developers/tebex.js/checkout)  - for allowing customers to make purchases without leaving your website.
* [`Tebex.portal`](https://docs.tebex.io/developers/tebex.js/payment-portal)  - for allowing existing customers to review their purchase history and subscriptions without leaving your website.
