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

# load()

> Load the browser agent and configure its Public Key, environment and timeout.

`load()` imports the browser agent and resolves to a `ShieldLabsAgent`. Loading alone does not start an identification.

```ts theme={null}
import { load } from '@shieldlabs-ai/js';

const agent = await load({ publicKey: 'PUBLIC_API_KEY' });
```

## Options

**publicKey** `string` *required*

Your domain's Public Key from **Integration > API keys**. Replace `PUBLIC_API_KEY` with that value. The SDK accepts 1–128 letters, digits, underscores or hyphens. It rejects server secrets beginning with `sec_` or `whsec_`.

**environment** `"production" | "development"` (default: production)

Selects the production or development agent host. Production loads `https://cdn.shieldlabs.ai/snippet.js`; development loads `https://dev.cdn.shieldlabs.ai/snippet.js`.

This selects a ShieldLabs service environment. For your own staging site, use a [separate registered domain](https://docs.shieldlabs.ai/setup/environments.md) with production services.

**timeout** `number` (default: 10000)

Milliseconds to wait for loading. Also sets the default timeout for agent calls. Must be greater than 0 and at most 2,147,483,647.

**scriptUrl** `string`

Advanced override for the agent module URL. Must be an absolute HTTPS URL; HTTP is accepted only for `localhost` and `127.0.0.1`. Overrides the host selected by `environment`. The SDK replaces any existing `publicKey` query parameter and removes the URL fragment.

Use only an endpoint configured for your integration. See the [CDN loading guidance](https://docs.shieldlabs.ai/setup/snippet.md#install-html).

## Return value

`Promise<ShieldLabsAgent>` resolves to an object with [`identify()`](https://docs.shieldlabs.ai/api/js-identify), [`check()`](https://docs.shieldlabs.ai/api/js-check) and [`identifyOnInteraction()`](https://docs.shieldlabs.ai/api/js-interaction).

Concurrent and repeated loads of the same resolved URL share one module import. Failed imports are retried by a later `load()` call. A timeout ends the wait; it does not cancel an import already in progress.

## Errors

`load()` rejects with `invalid_options`, `unsupported_environment`, `load_failed` or `timeout`. Call it in a browser page over HTTPS or localhost, after any consent gate your integration requires. Server rendering and workers are unsupported.

See [error handling](https://docs.shieldlabs.ai/api/js-errors.md) for the error fields and recovery steps.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.