Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Kinde · Function

getStringFlag

Retrieves a string feature flag from the user's access token. An optional string fallback handles a flag that is not found.

How it works

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.

Syntax

kinde.getStringFlag(code, defaultValue)

Parameters

NameTypeDescription
codestringName or code of the feature flag to retrieve.
defaultValuestring, optionalString returned if the flag is not found.

Returns

string

Key points

  • The helper obtains a string-valued flag from the access token's feature_flags claim.
  • code identifies which feature flag to retrieve.
  • defaultValue supplies a string fallback for an absent flag.
  • The documented call pattern passes a flag code followed by a default string.

Common mistakes

  • Provide a default value when using the documented JavaScript SDK helper.

Example: Read a string feature flag

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.

When to use it

Theme selection

Choose a user's visual theme while retaining a safe application default.

Personalized configuration

Toggle string-based UI or product configuration per user.

Interview questions

QWhat does getStringFlag read, and what are its arguments?

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.

QWhat does the defaultValue parameter do?

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".

QWhat happens when the flag has the wrong type?

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.

  • getFlag
  • getBooleanFlag
  • getIntegerFlag
  • feature_flags

Source: JavaScript SDK - Kinde docs. Checked 2026-10-15.