> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bily.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK overview

> Find every public method and TypeScript type exported by @bilyai/js.

`@bilyai/js` gives you one small browser SDK for loading Bily and sending events. It supports ESM, CommonJS, and TypeScript with no runtime dependencies.

## Install Bily

```bash theme={null}
npm install @bilyai/js
```

Use Node.js 16 or newer for build tooling. You can call every public method during server rendering; tracking begins only when the code runs in a browser document.

## Choose a method

| Export                                                       | Return type      | Purpose                                    |
| ------------------------------------------------------------ | ---------------- | ------------------------------------------ |
| [`init(options)`](/api-reference/init)                       | `void`           | Load Bily from an exact tracking URL       |
| [`track(event, payload?)`](/api-reference/track)             | `void`           | Queue or send an event                     |
| [`ready()`](/api-reference/ready)                            | `Promise<void>`  | Verify that Bily finished loading          |
| [`getBilyTrackingId()`](/api-reference/get-bily-tracking-id) | `string \| null` | Read or create the Bily browser identifier |

## Use exported types

```typescript theme={null}
import type {
  BilyAddress,
  BilyClient,
  BilyEvent,
  BilyInitOptions,
  BilyLegacyInitOptions,
  BilyOrder,
  BilyPayload,
  BilyProduct,
  KnownBilyEvent,
} from "@bilyai/js";
```

See [event names](/api-reference/events) and [payload types](/api-reference/payload) for the complete definitions.

## Start now, verify when needed

```typescript analytics.ts theme={null}
import { init, ready, track } from "@bilyai/js";

init({
  scriptUrl: "https://tracking.example.com/b.js?shop=store.example.com",
});

track("workspace_created", { workspace_id: "workspace_456" });

try {
  await ready();
} catch (error) {
  console.error("Bily failed to load", error);
}
```

You can call `track()` before `ready()` resolves. The SDK keeps early calls in a bounded queue, then delivers them in order after Bily loads.

<Warning>
  Do not add a raw script tag alongside the SDK. `init()` loads the browser script for you.
</Warning>
