Authentication
object
Both auth()
and getAuth()
return an Authentication
object. This JavaScript object contains important information like session data, your user's ID, as well as their active organization ID.
Properties
Name | Description |
---|---|
actor | Holds identifier for the user that is impersonating the current user. |
debug | Used to help debug issues when using Clerk in development. |
getToken | A function that returns a promise that resolves to the current user's session token. Can also be used to retrieve a custom JWT template. |
has | A function that returns a boolean based on the permission or role provided as parameter. Can be used for authorization. |
orgId | The current user's active organization ID. |
orgRole | The current user's active organization role. |
orgPermissions | The current user's active organization permissions. |
orgSlug | The current user's active organization slug. |
organization | The current user's active organization object. |
sessionClaim | The current user's session claim. |
sessionId | The current user's session ID. |
userId | The current user's unique identifier. |
Example
{ sessionId: 'sess_2GaMqUCB3Sc1WNAkWuNzsnYVVEy', userId: 'user_2F2u1wtUyUlxKgFkKqtJNtpJJWj', orgId: null, orgRole: null, orgSlug: null, orgPermissions: null, has: [Function (anonymous)], getToken: [AsyncFunction (anonymous)], claims: { azp: 'http://localhost:3000', exp: 1666622607, iat: 1666622547, iss: 'https://clerk.quiet.muskox-85.lcl.dev', nbf: 1666622537, sid: 'sess_2GaMqUCB3Sc1WNAkWuNzsnYVVEy', sub: 'user_2F2u1wtUyUlxKgFkKqtJNtpJJWj' } }
Example with active organization
{ sessionId: 'sess_2GaMqUCB3Sc1WNAkWuNzsnYVVEy', userId: 'user_2F2u1wtUyUlxKgFkKqtJNtpJJWj', orgId: 'org_2ZVFfVAkt4ocVjHL0KTdL94AhXK', orgRole: 'org:admin', orgSlug: undefined, orgPermissions: ['org:team_settings:manage'], // Custom permissions has: [Function (anonymous)], getToken: [AsyncFunction (anonymous)], claims: { azp: 'http://localhost:3000', exp: 1666622607, iat: 1666622547, iss: 'https://clerk.quiet.muskox-85.lcl.dev', nbf: 1666622537, sid: 'sess_2GaMqUCB3Sc1WNAkWuNzsnYVVEy', sub: 'user_2F2u1wtUyUlxKgFkKqtJNtpJJWj' } }