How to get custom claim inside onRedirectCallback? (React Provider)

I’ve added a custom claim property with Auth0 Actions, called logins_count to determine if a user has just signed up or not.

Based on that, we want to redirect to different pages (welcome screen), or possibly other logic.
This is currently handled in onRedirectCallback. This callback gives us (appState, user). But the user object doesn’t contain the claim data.

So you might say to use getIdTokenClaims(), but I can’t use that in the callback, because I have to do

const { getIdTokenClaims } = useAuth0()

<Auth0Provider
  ...
  onRedirectCallback={async (appState, user) => {
    const ... = await getIdTokenClaims()
  }}
/>

which isn’t possible because the getIdTokenClaims is from the hook which is outside the provider.

I can potentially use the hook from a child, but there I don’t have access to appState from the callback.

So what am I supposed to do here? (Seems the callback is a port from a node project, and not quite used in the “react way”)

Hi,
You can use a combination of useEffect and your existing logic.
After the user authenticates, grab the token claims with getIdTokenClaims() inside a component that has access to the Auth0 hook. Once you have those claims, you can redirect based on them.
Cheers,
Harsh

Yes, I already know that. But maybe you didn’t read this line:

I can potentially use the hook from a child, but there I don’t have access to appState from the callback.

I don’t know what you mean “combine”. They happen independently, but I need both values in the same place