Skip to content
  • Workflows
  • Bindings

kinde.idToken

The kinde.idToken binding lets you modify ID tokens for the current user. When you add custom claims, these are included in the ID token returned to the client.

setCustomClaim(name: string, value: any): void

Link to this section

Adds a custom claim to the ID token. The claim will be available when the token is returned to the client.

Available in workflows

Link to this section
export const workflowSettings = {
// ...other settings
bindings: {"kinde.idToken": {}}
};
Link to this section

The Kinde infrastructure library provides type-safe ID token modification:

import { idTokenCustomClaims } from "@kinde/infrastructure";
export default async function (event: onUserTokenGeneratedEvent) {
const idToken = idTokenCustomClaims<{
userRole: string;
lastLogin: string;
}>();
idToken.userRole = "admin";
idToken.lastLogin = new Date().toISOString();
};

Using the low-level API

Link to this section

If you’re not using the infrastructure library, you can modify the ID token directly:

kinde.idToken.setCustomClaim("userRole", "admin");
kinde.idToken.setCustomClaim("lastLogin", new Date().toISOString());