Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document sessionClaims property for useAuth #1831

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ijxy
Copy link

@ijxy ijxy commented Dec 20, 2024

⚠️ Requires clerk/javascript#4823 to be merged

Explanation:

This PR:

This documents the sessionClaims property for the various implementations of useAuth as added in clerk/javascript#4823 and which https://clerk.com/docs/backend-requests/making/custom-session-token#use-the-custom-claims-in-your-application actually claims is already available

Checklist

  • I have clicked on "Files changed" and performed a thorough self-review
  • I have added the "deploy-preview" label and added the preview link(s) to this PR description
  • All existing checks pass

@ijxy ijxy requested a review from a team as a code owner December 20, 2024 12:45
@ijxy ijxy changed the title docs(react): document sessionClaims property for useAuth document sessionClaims property for useAuth Dec 20, 2024
@alexisintech
Copy link
Member

Requires clerk/javascript#4823 to be merged

Side note: I'm not sure if this will actually get merged - it was my mistake to say that you can access the Auth object using useAuth() - it's not true. you can access the Auth object server-side, and if you need some of those properties client-side, you can use the useAuth() hook but not all properties will be available, such as sessionClaims.
I made this fix in this PR: #1836
For example, you can see the specific diff here: https://github.com/clerk/clerk-docs/pull/1836/files#diff-32a8aa53d6ed186d319a0345942cd6e8ecc0600e08948fd37f10de0d8b7ab135R8

@ijxy
Copy link
Author

ijxy commented Jan 10, 2025

Hi @alexisintech, thanks for your feedback!

I appreciate that it not an easy job keeping documentation up to date, especially when the terminology is so overloaded.

Technically, you can already access the sessionClaims on the client, using the useSession hook (see below). Regardless of whether my proposed change to make them accessible from useAuth are accepted, perhaps this is worth mentioning too. Something for you to decide!

// has the type `JWTClaims` instead of `JWTPayload` (which is the type that inherits the
// custom session claims), but does actually contain the custom claims
useSession().session?.lastActiveToken?.jwt?.claims 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants