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

Kinde · Module

getIntegerFlag

Gets an integer feature flag for the current Kinde session. A numeric default can be supplied for an unset flag.

How it works

Call the method with a flag code and a numeric fallback. It reads the integer feature flag associated with the current access token; supplying a default prevents a missing flag from producing an error.

Syntax

getIntegerFlag(code, defaultValue)

Parameters

NameTypeDescription
codestringThe feature-flag code to check.
defaultValuenumberThe numeric value returned when the flag is not set.

Returns

number | Error

Key points

  • The method retrieves an integer feature flag from the current access token.
  • Use code to name the feature flag being requested.
  • defaultValue controls the number returned when the requested flag is missing.
  • In the server-side Next.js SDK, obtain the method from the Kinde server-session helper and await it.
  • The documented result is either a number or an Error.

Common mistakes

  • Provide the fallback value when calling this method; the page marks defaultValue as required.

Example: Read an integer feature flag

import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";

export async function GET() {
  const { getIntegerFlag } = getKindeServerSession();
  const billingVersion = await getIntegerFlag("billingVersion", 0);
  return Response.json({ billingVersion });
}

Reads the integer feature flag and uses 0 when the flag is not configured.

When to use it

Select a rollout or billing version

Gradual rollouts

Read a per-user or per-organization numeric limit

Quota configuration

Keep behavior deterministic when configuration is absent

Safe defaults

Interview questions

QWhat does getIntegerFlag do?

getIntegerFlag reads an integer feature flag for the current session and returns a number. The method accepts the flag code and a default number used when the flag is not set.

Follow-up: What should the application do if the flag is absent? Pass an explicit fallback so the feature has deterministic behavior.

QWhat are the method's arguments?

The first argument identifies the flag, while defaultValue supplies the value to use when that flag is unavailable. In the Next.js server SDK, the method is obtained from getKindeServerSession and awaited.

Follow-up: How would you expose the result from a route? Read the flag in the handler, then include the resulting number in the response.

QWhat does the method return?

The documented result is a number or an Error. A numeric default is therefore useful when a feature flag may not exist.

Follow-up: How can a caller distinguish a configured value from a fallback? The method alone does not provide that distinction; track configuration separately or use a lower-level flag API if needed.

  • getBooleanFlag
  • getFlag
  • getStringFlag
  • getKindeServerSession

Source: Next.js App Router SDK - Kinde docs. Checked 2026-10-15.