How do I change the content of my Javascript project depending on the keycloak group the user is in?

I’m developing a javascript project using keycloak for authentication, and I’d like the contents of the application to change depending on the type of user who logs in. For example:

If the user is as user, it will show on the screen that he is a user
If the user is as admin, it will show on the screen that he is an admin

Some approaches here. Let’s say you identify the rights based on Keycloak (KC) roles:

  1. OAuth 2.0 Approach: You can add the user’s roles to the access token and utilize them when your app calls your APIs (where your APIs act as OAuth 2.0 RS).
  2. OIDC Approach: You can add the user’s roles to the ID token, thereby enriching the identity information.

You can also combine both approaches as needed, or add that information to the userinfo endpoint.