Type-safe values
Boolean, string, number, JSON, and generic return types.
Developer tools
Typed JavaScript and React SDKs for flags, detailed evaluations, experiments, and survey delivery—with a small API surface and predictable fallbacks.
npm install @fujiflag/jsnpm install @fujiflag/reactCreate 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.
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
Use a value-only API in ordinary UI code, then switch to detailed evaluation where analytics or debugging needs the decision metadata.
Boolean, string, number, JSON, and generic return types.
Choose a cache TTL that fits the sensitivity of each application.
Expire cached values on an interval or clear the cache before the next read.
Public evaluation keys cannot mutate workspace configuration.
React quickstart
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.
new-checkout as a boolean flag and set its environment value to false.true and reload after clearing or expiring the SDK cache.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
Choose cache and error behavior deliberately before putting a flag on a critical application path.
Targeting and experiments
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 experimentsclient.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
JavaScript SDK
A framework-agnostic client for browser, Node.js, ES modules, CommonJS, and script tags.
React SDK
A provider and focused hooks that keep evaluation state natural inside React applications.
Start small. Ship safely.
Create a free workspace, copy the environment read key, and add FujiFlag to an existing JavaScript or React application.
No credit card required.