Skip to content

Provide TypeScript types for documented JWT claims fields (email, phone, user_metadata, etc.) #1584

@RobSchilderr

Description

@RobSchilderr

Refactor Request

Describe the refactor

The getClaims() method returns JwtPayload with type RequiredClaims & { [key: string]: any }, which doesn't provide TypeScript types for common Supabase JWT fields that are documented in
the JWT Claims Reference.

const { data } = await supabase.auth.getClaims()
data.claims.email        // No TypeScript support
data.claims.user_metadata // No TypeScript support

The documented fields like email, phone, user_metadata, app_metadata, and is_anonymous exist at
runtime but aren't typed, making developers lose autocomplete and type safety. I understand why you did it, but it doesn't make it smooth to work with.

getUser() returns a properly typed User object with these fields, but getClaims() loses this type
information despite returning the same data from the JWT.

Additional context

Would you consider providing TypeScript types for these documented JWT fields, or what's the
recommended approach for type-safe access to these claims when using getClaims()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    auth-jsRelated to the auth-js library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions