> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# JavaScript API

Rslib provides a comprehensive JavaScript API for developers to directly use Rslib's capabilities in JavaScript or TypeScript code.

Rslib's JavaScript API can be used in Node.js, Deno, or Bun.

## Getting started

This basic example demonstrates how to use the Rslib JavaScript API.

### 1. Install Rslib

Install the `@rslib/core` package:


```sh [npm]
npm add @rslib/core -D
```

```sh [yarn]
yarn add @rslib/core -D
```

```sh [pnpm]
pnpm add @rslib/core -D
```

```sh [bun]
bun add @rslib/core -D
```

```sh [deno]
deno add npm:@rslib/core -D
```

### 2. Create an Rslib instance

Call the [createRslib](/api/javascript-api/core.md#createrslib) method to create an Rslib instance:

```ts
import { createRslib } from '@rslib/core';

const rslib = await createRslib();
```

The `createRslib` method accepts various options. Learn more in the [API - createRslib](/api/javascript-api/core.md#createrslib) documentation.

### 3. Call Rslib instance methods

The Rslib instance provides several methods for different scenarios.

For example, when building the output, use the [rslib.build](/api/javascript-api/instance.md#rslibbuild) method which will build production outputs:

```ts
await rslib.build();
```

:::tip

For more information about Rslib instance methods, see the [Rslib instance](/api/javascript-api/instance.md) documentation.

:::

These three steps cover the basic usage of Rslib. Next, you can customize the build process with Rslib configurations and [Rsbuild plugins](https://rsbuild.rs/plugins/dev/).

## Export formats

Rslib only supports ES Modules formats:

```js title="index.mjs"
import { createRslib } from '@rslib/core';
```
