Theme selection
Choose a user's visual theme while retaining a safe application default.
Kinde · Function
Retrieves a string feature flag from the user's access token. An optional string fallback handles a flag that is not found.
Call getStringFlag with a flag code and a string fallback. It reads the string feature flag from the access token's feature_flags claim; the fallback is used when the flag is not set, while a wrong flag type is invalid.
kinde.getStringFlag(code, defaultValue)| Name | Type | Description |
|---|---|---|
code | string | Name or code of the feature flag to retrieve. |
defaultValue | string, optional | String returned if the flag is not found. |
string
const theme = kinde.getStringFlag("theme", "system");
console.log(theme);Reads the user's string-valued theme flag and uses "system" when the flag is unavailable.
Choose a user's visual theme while retaining a safe application default.
Toggle string-based UI or product configuration per user.
It retrieves a string feature flag from the access token's feature_flags claim. The first argument identifies the flag, and the second supplies a fallback value.
Follow-up: What should happen if the flag is missing? Use the provided default; without one, the SDK reports an error.
The method returns a string value. Its default value is returned when the requested flag is not found.
Follow-up: How would you avoid an exception for optional configuration? Pass an explicit string fallback such as "system".
The requested flag must actually be string-typed. Calling this helper for a boolean flag causes a type error rather than converting the value.
Follow-up: Which helper should be used for a boolean flag? Use the SDK's boolean-flag helper instead of getStringFlag.
getFlaggetBooleanFlaggetIntegerFlagfeature_flags