> ## 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.

# ready()

> Confirm that Bily finished loading when your application needs an explicit check.

Use `ready()` when you need to confirm that Bily loaded. Normal event tracking does not wait for it because `track()` queues early calls.

## Check readiness

```typescript theme={null}
function ready(): Promise<void>;
```

## Verify the installation

In the browser, call `init()` before awaiting `ready()`.

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

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

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

## Know when it resolves

The promise resolves when Bily can accept queued events. During server rendering, it resolves immediately because there is no browser script to load.

## Handle a rejection

The promise rejects when:

* The browser reports a script load error.
* Bily does not become ready before `loadTimeoutMs`.
* The script loads but does not expose a usable Bily browser API.

The default timeout is 15 seconds. Set a value from 1 to 60 seconds through `init()`.

## Retry one failed load

After a terminal load failure, call `init()` again. Then call `ready()` for the new attempt.

```typescript theme={null}
async function loadBily() {
  const options = {
    scriptUrl: "https://tracking.example.com/b.js?shop=store.example.com",
  } as const;

  init(options);

  try {
    await ready();
  } catch {
    init(options);
    await ready();
  }
}
```

If production keeps failing, check the URL, network policy, and duplicate installation. Do not retry indefinitely.

<Card title="Troubleshooting" icon="screwdriver-wrench" href="/troubleshooting">
  Resolve timeouts, script errors, and conflicting configuration.
</Card>
