Flagsmith
The Flagsmith provider for the Flags SDK contains support for Flagsmith's Feature Flags and Remote Configuration.
Learn more about Adapters
Deploy the template
Setup
The Flagsmith provider is available in the @flags-sdk/flagsmith module. You can install it with
Set the required environment variable:
Usage
The Flagsmith adapter provides a getValue() method with optional type coercion:
Type Coercion Behavior
- Without
coerce: Returns the raw value from Flagsmith (empty/null/undefined values return default) coerce: "string": Converts any value to string (returns default for null/undefined/NaN)coerce: "number": Converts strings to numbers (returns default if result is NaN or invalid)coerce: "boolean":- Converts
"true"/"false"strings (case-insensitive) to boolean - Converts
0tofalseand1totrue - Falls back to the flag's enabled state for other values
- Returns default when flag is disabled
- Converts
Default Adapter
The default flagsmith adapter is export as flagsmithAdapter.
This adapter automatically configures itself based on the following Environment variables:
FLAGSMITH_ENVIRONMENT_ID(required): Your Flagsmith environment ID
Custom Adapter
Create a custom adapter by using the createFlagsmithAdapter function:
Flags Discovery Endpoint
To enable the Flags Explorer, create a discovery endpoint at app/.well-known/vercel/flags/route.ts:
This endpoint fetches flag definitions directly from Flagsmith's API and returns them to the Flags Explorer.
Environment Variables
FLAGSMITH_ENVIRONMENT_ID(required): Your Flagsmith environment IDFLAGSMITH_PROJECT_ID(optional): Required for the Flags Discovery Endpoint