Overview
TheUserInfo component displays a user’s profile information, including their name, email, and profile picture. It supports fetching user data dynamically if no user is provided initially.
Installation
Ensure you have the required dependencies installed:- Preview
- Component
Props
| Name | Type | Description |
|---|---|---|
user | User | null | undefined | The user object, if already available. |
fetchUrl | string (optional) | API endpoint to fetch user data if not provided. Defaults to "/api/me". |
profilePicturePlaceholder | React.ReactElement (optional) | Placeholder component for the profile picture if the user has none. |
User Type
TheUser type includes:
Features
- Displays user information: Name, email, profile picture, and account creation date.
- Email verification badge: Shows a verification badge if the email is verified.
- Auto-fetches user data: If
useris not provided, it fetches data fromfetchUrl. - Customizable profile picture placeholder: Supports a fallback element.
Example with Preloaded User Data
Example with Fallback Image
- If
useris provided, the component will not make a fetch request. - Profile pictures are displayed if available; otherwise, a random gradient is used as a placeholder.
- The component ensures proper accessibility by setting the
altattribute for images.
Theming
The component is styled using tailwind. It can be customized using theclassName and buttonText props,
or using Tailwind CSS theme variables. You can find more details and full examples in the customization doc.
In addition, the hooks documented for each component can be used if you’d like to use Nile Auth with your own components.
If needed, you can peek at the source code of the component and use it as a template to create your own component for maximum customization.