Files
supabase/apps/ui-library/content/docs/tanstack/current-user-avatar.mdx
Ivan Vasilov 429aa9d084 fix: More fixes for UI Library (#34552)
* Add realtime chat to the landing page.

* Fix the realtime cursor demo on the landing page.

* Fix a bad spelling of shadcn.

* Fix the wrong link in RR auth.

* Change the demo for reatlime cursor to use predefined names.

* Fix the React Router auth block docs.

* Regenerate the realtime chat code.

* Add a docs field to the clients blocks. Add a missing package to the nextjs client block.

* Add links to additional docs on the auth blocks pages.

* Add additional links to the current user avatar docs.

* Add additional links to the client docs.

* Add additional links to the dropzone docs.

* Add additional links to the avatar stack.

* Add additional links to the realtime cursor.

* Add additional links to the realtime chat.

* Fix the dropzone links.
2025-03-31 18:40:03 +08:00

50 lines
1.5 KiB
Plaintext

---
title: Current User Avatar
description: Supabase Auth-aware avatar
---
<ComponentPreview name="current-user-avatar-demo" showCode={false} />
## Installation
<BlockItem
name="current-user-avatar-tanstack"
description="Renders the avatar of the current user."
/>
## Folder structure
<RegistryBlock itemName="current-user-avatar-tanstack" />
## Introduction
The `CurrentUserAvatar` component connects to Supabase Auth to fetch the user data and show an avatar. It uses the `user_metadata`
property which gets populated automatically by Supabase Auth if the user logged in via a provider. If the user doesn't have a profile image, it renders their initials. If the user is logged out, it renders a `?` as a fallback, which you can change.
## Usage
The `CurrentUserAvatar` component is designed to be used anywhere in your app. Add the `<CurrentUserAvatar />` component to your page and it will render the avatar of the current user, with a fallback.
```tsx
import { CurrentUserAvatar } from '@/components/current-user-avatar'
const CurrentUserAvatarDemo = () => {
return (
<Header className="flex items-center justify-between">
<h1>Lumon Industries</h1>
<CurrentUserAvatar />
</Header>
)
}
export default CurrentUserAvatarDemo
```
## Props
This component doesn't accept any props. If you wish to change the fallback, you can do so by changing the `CurrentUserAvatar` component directly.
## Further reading
- [Auth users](https://supabase.com/docs/guides/auth/users)