Developer tools

Feature flag SDKs for JavaScript and React.

Typed JavaScript and React SDKs for flags, detailed evaluations, experiments, and survey delivery—with a small API surface and predictable fallbacks.

Install
npm install @fujiflag/jsnpm install @fujiflag/react

Create a boolean flag named new-checkout and copy a read key from the environment you want to evaluate. Set baseURL explicitly when using the hosted API.

ESMCommonJSBrowserNode
import { createFujiFlagClient } from '@fujiflag/js';

const client = createFujiFlagClient({
  apiKey: 'ff-pk-your-environment-read-key',
  baseURL: 'https://api.fujiflag.com',
  cacheTTL: 60 * 1000,
});

async function isCheckoutEnabled() {
  try {
    return (await client.getFlagValue<boolean>(
      'new-checkout', false,
    )) === true;
  } catch {
    // Keep the current checkout if the API is unavailable.
    return false;
  }
}

const enabled = await isCheckoutEnabled();
console.log({ enabled });

Designed for the code path

Small primitives. Enough context when you need it.

Use a value-only API in ordinary UI code, then switch to detailed evaluation where analytics or debugging needs the decision metadata.

Type-safe values

Boolean, string, number, JSON, and generic return types.

Configurable caching

Choose a cache TTL that fits the sensitivity of each application.

Explicit refresh control

Expire cached values on an interval or clear the cache before the next read.

Read-only clients

Public evaluation keys cannot mutate workspace configuration.

React quickstart

A provider, a hook, and a safe first render.

Install @fujiflag/react, wrap your application with FujiFlagProvider, and read a flag with useFlag. The hook exposes loading and error states so your existing experience stays usable while evaluation completes.

  1. Create a project and choose a development or staging environment.
  2. Create new-checkout as a boolean flag and set its environment value to false.
  3. Replace the example key with that environment's read key. Change the flag to true and reload after clearing or expiring the SDK cache.
React SDK guide
import { FujiFlagProvider, useFlag } from '@fujiflag/react';

function CheckoutButton() {
  const { value, loading, error } = useFlag<boolean>(
    'new-checkout', false,
  );
  const enabled = !loading && !error && value === true;

  return (
    <button>
      {enabled ? 'Try new checkout' : 'Checkout'}
    </button>
  );
}

export default function App() {
  return (
    <FujiFlagProvider config={{
      apiKey: 'ff-pk-your-environment-read-key',
      baseURL: 'https://api.fujiflag.com',
      cacheTTL: 60 * 1000,
    }}>
      <CheckoutButton />
    </FujiFlagProvider>
  );
}

Runtime behavior

Know what happens between reads.

Choose cache and error behavior deliberately before putting a flag on a critical application path.

API endpoint and environment
Set baseURL to https://api.fujiflag.com for the hosted service; the SDK default is http://localhost:8080. The read key selects the project and environment, so use a separate key for staging and production.
Caching and refresh
cacheTTL is measured in milliseconds and defaults to five minutes. clearCache() forces the next read to fetch again. refreshInterval periodically clears the cache; it does not push updates into an already rendered React component. Call stopPolling() when a manually created client is no longer needed.
Missing flags and network errors
Pass a fallback as the second argument to getFlagValue or useFlag for a missing key. JavaScript request failures still reject, so catch them explicitly. In React, handle loading and error before using the returned value.
Read keys and targeting context
Use read keys in browser integrations and keep management credentials on your server. Use an opaque targetingKey for stable rollouts and experiments. Client-side flags and browser-supplied attributes must not replace server-side authorization.
Read the API-key guide

Targeting and experiments

Understand why a value was returned.

Configure audience rules and an experiment in the dashboard, then pass the subject's evaluation context to the client. getFlagEvaluation returns the value and available decision metadata; use it when connecting exposure events to your own analytics.

Decision reasons include TARGET_MATCH, ROLLOUT, FALLBACK, and SPLIT. Experiment fields are present for running experiment assignments. This response supplies assignment context; your application decides when an exposure occurred and where to record it.

Explore feature experiments
client.setEvaluationContext({
  targetingKey: 'opaque-visitor-123',
  plan: 'pro',
});

try {
  const { value, detail } =
    await client.getFlagEvaluation<boolean>('new-checkout', false);

  console.log({
    enabled: value === true,
    reason: detail?.reason,
    variant: detail?.variant,
    experiment: detail?.experimentKey,
    version: detail?.experimentVersion,
  });
} catch {
  // Keep your application's safe default on request failure.
}

Choose your integration

The same evaluation contract, with the ergonomics your app expects.

JavaScript SDK

@fujiflag/js

A framework-agnostic client for browser, Node.js, ES modules, CommonJS, and script tags.

  • Single and bulk flag reads
  • Detailed experiment evaluation
  • Evaluation context
  • Survey runtime and custom renderer
View package Read the SDK guide

React SDK

@fujiflag/react

A provider and focused hooks that keep evaluation state natural inside React applications.

  • FujiFlagProvider
  • useFlag and useFlags
  • useFlagEvaluation metadata
  • Survey delivery hook and host
View package Read the SDK guide

Start small. Ship safely.

Get from install to first evaluation.

Create a free workspace, copy the environment read key, and add FujiFlag to an existing JavaScript or React application.

No credit card required.