Sending UserID securely from NextJS Auth0 App to APIs


Many of my APIs require user_id to be sent. However the user_id is quite sensitive information.

I am using nextjs 13 with app router, and i am trying to define a GET api function which fetches the Access Token.

I dont want to complicate things, but I have tried chatgpt, numerous documentation/quickstarts, but none of them are showing this very basic task.

I can already login/logout and access user information to display on the frontend. But I want the secure JWT token that has the user information within it.

As a newbie, please can someone show me how to achieve the following:

  • Retrieve Access Token containing user information (JWT Token that when decoded will have user.sub)
  • log this to console.

Usually when I ask for help on this topic I get directed to react Auth0 docs or a solution that uses the old NextJS page router. If there is an example for the next js 13 app router please let me know.

Hi @virajvaitha1995,

Our docs have an example:

Have you tried this? If so, what isn’t working for you?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.