> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.fujiflag.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.fujiflag.com/_mcp/server.

# JavaScript SDK

> Read FujiFlag values from JavaScript, TypeScript, browsers, or Node.js.

# JavaScript SDK

`@fujiflag/js` is the framework-agnostic FujiFlag SDK. It supports browsers and
Node.js, has no external dependencies, and can cache and poll flag values.

## Install

```bash
npm install @fujiflag/js
```

## Create a client

```ts
import { createFujiFlagClient } from "@fujiflag/js";

const client = createFujiFlagClient({
  apiKey: "ff-pk-your-api-key-here",
  baseURL: "https://api.fujiflag.com",
  cacheTTL: 5 * 60 * 1000,
  refreshInterval: 60 * 1000,
});
```

`baseURL` is optional. Use it when connecting to a self-hosted or local FujiFlag
API. `cacheTTL` and `refreshInterval` are optional and expressed in milliseconds.

## Read one value

```ts
const enabled = await client.getFlagValue<boolean>("new-checkout");
```

## Read all values

```ts
const flags = await client.getFlagValues();
console.log(flags);
```

## Browser script tag

```html
<script src="https://unpkg.com/@fujiflag/js/dist/index.umd.js"></script>
<script>
  const client = FujiFlag.createClient({
    apiKey: "ff-pk-your-api-key-here",
    baseURL: "https://api.fujiflag.com"
  });
</script>
```

For the complete package surface, see the
[SDK README](https://github.com/haris-syed/FujiFlag/tree/main/fujiflag-js).