Skip to main content

useCurrentUserInfo Hook

Access the current authenticated DHIS2 user's information from the Provider

Basic Usage:

import { useCurrentUserInfo } from '@dhis2/app-runtime'

// Within a functional component body
const user = useCurrentUserInfo()

Input

None

Output

This hook returns an object of type CurrentUser

Example

import React from 'react'
import { useCurrentUserInfo } from '@dhis2/app-runtime'

export const MyComponent = () => {
const user = useCurrentUserInfo()
return (
<div>
<span>
<strong>Display Name</strong> : {user.displayName}
</span>
<span>
<strong>Username</strong> : {user.username}
</span>
</div>
)
}