# JavaScript quickstart

> Wire the browser SDK into your app and see your first flag fetch.

Wire the browser SDK into your app in three steps. This assumes you've already
created a flag and copied a `development` SDK key — if not, start with the
[Quickstart](/docs/quickstart).

## 1. Install

```bash
npm install switchbox-js
```

`switchbox-js` has **zero runtime dependencies** — it uses only the browser's
`fetch` and Web Crypto APIs.

## 2. Create a client

Use the `Switchbox.create()` factory — it constructs the client and awaits the
first config fetch, so the client is ready to evaluate as soon as it resolves.
Create it once and reuse it.

```js
import { Switchbox } from 'switchbox-js';

const client = await Switchbox.create({
  sdkKey: 'your-sdk-key-from-dashboard',
});
```

## 3. Check a flag

Evaluation is **async** (it uses Web Crypto for rollout hashing), so `await` it:

```js
if (await client.enabled('new_checkout', { user_id: '42' })) {
  showNewCheckout();
} else {
  showOldCheckout();
}
```

The user object is optional — pass it when a flag uses targeting rules or a
percentage rollout. After the first fetch, evaluation is a local lookup against
the cached config; the SDK refreshes it in the background every 10 seconds.

When you're done (e.g. tearing down a session), stop the poller:

```js
client.destroy();
```

## See it connect

Load the page that creates the client. Within a few seconds, the `development`
environment in the dashboard shows a **Connected ✓** badge — your client is
fetching its config from the edge.

Flip the flag in the dashboard and **Save**; the running page picks up the change
on its next poll (within ~10 seconds).

## Where to next

- [JavaScript SDK reference](/docs/sdk/javascript) — methods, options, and the
  `onEvaluation` hook for analytics.
- [React quickstart](/docs/quickstart/react) — if you're using React, use the
  hooks instead.
- [Targeting rules](/docs/concepts/targeting) and
  [rollouts](/docs/concepts/rollouts).
- [Use with OpenFeature](/docs/sdk/openfeature): already on the vendor-neutral API? Switchbox is one provider line.
