mirror of
https://github.com/supabase/supabase.git
synced 2026-06-01 18:34:37 +08:00
Format files. Run `pnpm format` at root. --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
49 lines
1.6 KiB
Plaintext
49 lines
1.6 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-vue" description="Renders the avatar of the current user." />
|
|
|
|
## Folder structure
|
|
|
|
This block assumes that you have already installed a Supabase client for Vue from the previous step.
|
|
|
|
<RegistryBlock itemName="current-user-avatar-vue" />
|
|
|
|
## 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.
|
|
|
|
```vue
|
|
<script setup lang="ts">
|
|
// Assumes you have Header component created
|
|
import CurrentUserAvatar from '@/components/CurrentUserAvatar.vue'
|
|
import Header from '@/components/Header.vue'
|
|
</script>
|
|
|
|
<template>
|
|
<Header class="flex items-center justify-between">
|
|
<h1>Lumon Industries</h1>
|
|
<CurrentUserAvatar />
|
|
</Header>
|
|
</template>
|
|
```
|
|
|
|
## 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)
|