Quickstart
Get started with Gatepost in under 2 minutes.
Install the SDK
bash
npm install @gatepost/clientGatepost is OpenFeature compatible, so you can also use the official OpenFeature SDK:
bash
npm install @openfeature/server-sdkInitialize the provider
typescript
import { GatepostProvider } from "@gatepost/client";
import { OpenFeature } from "@openfeature/client";
await OpenFeature.setProvider(new GatepostProvider({
apiKey: process.env.GATEPOST_API_KEY,
}));Get your API key from the Gatepost Dashboard.
Evaluate flags
Once initialized, use any OpenFeature client to evaluate flags:
typescript
const client = OpenFeature.getClient();
// Boolean flags
const enabled = await client.getBooleanValue("new-checkout", false);
// String flags
const theme = await client.getStringValue("theme", "light");
// Number flags
const threshold = await client.getNumberValue("threshold", 100);
// JSON flags
const config = await client.getObjectValue("config", {});Targeting with attributes
Pass user attributes for targeted evaluations:
typescript
const enabled = await client.getBooleanValue("premium-feature", false, {
attributes: {
plan: "premium",
country: "US",
email: "user@company.com"
}
});Percentage rollouts
Use stable user bucketing for gradual rollouts:
typescript
const enabled = await client.getBooleanValue("new-feature", false, {
rolloutPercentage: 25 // 0-100
});That's it! Continue to the Core Concepts to learn more.