# 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`](/developers/tebex.js/checkout.md)  - for allowing customers to make purchases without leaving your website.
* [`Tebex.portal`](/developers/tebex.js/payment-portal.md)  - for allowing existing customers to review their purchase history and subscriptions without leaving your website.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tebex.io/developers/tebex.js/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
