Read identity-token data
Inspect the authenticated user’s raw identity token for client-side processing.
Kinde · Module
getIdToken asynchronously returns Kinde’s raw ID token from memory. It accepts no arguments and may resolve to undefined when no ID token is available.
Call getIdToken without arguments to asynchronously retrieve the raw ID token held in memory. The promise resolves to the token string when one is available, or undefined otherwise.
await kinde.getIdToken()Promise<string | undefined>
import { kinde } from "@kinde/js-utils";
const idToken = await kinde.getIdToken();
console.log(idToken);Awaits the raw ID token currently held in memory and logs it when available.
Inspect the authenticated user’s raw identity token for client-side processing.
Access organization-related claims included in the ID token.
Replace deprecated token retrieval usage in the new authentication flow.
getIdToken is an asynchronous JavaScript SDK method that returns the raw ID token from memory. Its return type is Promise<string | undefined>, so callers should await it and account for the token being unavailable.
Follow-up: How would you distinguish it from an access-token helper? getIdToken returns the ID token, which carries identity-oriented claims; an access-token helper is used when authorizing API calls.
The method takes no arguments in the current API. The documentation marks the older getIdToken(options) form as deprecated.
Follow-up: What should a migration preserve? Remove the options argument and handle the promise result as possibly undefined.
The SDK keeps the raw ID token in memory and getIdToken retrieves it asynchronously. The result can be a string or undefined, so code should not assume authentication has produced a value.
Follow-up: What should code do when the result is undefined? Treat the user as lacking an available ID token and use the application’s authentication or reauthentication path.
getTokenid_tokenorg_codepermissionskinde