Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: avatar and avatar stack for vue & nuxt (#43036)

Jakub Andrzejewski54ac9fff25f4
diff --git a/apps/ui-library/config/docs.ts b/apps/ui-library/config/docs.ts
index 680fc13deff..17302b7ff19 100644
--- a/apps/ui-library/config/docs.ts
+++ b/apps/ui-library/config/docs.ts
@@ -90,14 +90,14 @@ export const componentPages: SidebarNavGroup = {
},
{
title: 'Current User Avatar',
- supportedFrameworks: ['nextjs', 'react-router', 'tanstack', 'react'],
+ supportedFrameworks: ['nextjs', 'react-router', 'tanstack', 'react', 'vue', 'nuxtjs'],
href: '/docs/nextjs/current-user-avatar',
items: [],
commandItemLabel: 'Current User Avatar',
},
{
title: 'Realtime Avatar Stack',
- supportedFrameworks: ['nextjs', 'react-router', 'tanstack', 'react'],
+ supportedFrameworks: ['nextjs', 'react-router', 'tanstack', 'react', 'vue', 'nuxtjs'],
href: '/docs/nextjs/realtime-avatar-stack',
items: [],
commandItemLabel: 'Realtime Avatar Stack',
diff --git a/apps/ui-library/content/docs/nuxtjs/current-user-avatar.mdx b/apps/ui-library/content/docs/nuxtjs/current-user-avatar.mdx
new file mode 100644
index 00000000000..e6f1ca864e5
--- /dev/null
+++ b/apps/ui-library/content/docs/nuxtjs/current-user-avatar.mdx
@@ -0,0 +1,51 @@
+---
+title: Current User Avatar
+description: Supabase Auth-aware avatar
+---
+
+<ComponentPreview name="current-user-avatar-demo" showCode={false} />
+
+## Installation
+
+<BlockItem
+ name="current-user-avatar-nuxtjs"
+ 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-nuxtjs" />
+
+## 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.
+
+```html
+<script setup lang="ts">
+// Asumes you have Header component created
+import Header from '@/components/Header.vue'
+import CurrentUserAvatar from '@/components/CurrentUserAvatar.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)
diff --git a/apps/ui-library/content/docs/nuxtjs/realtime-avatar-stack.mdx b/apps/ui-library/content/docs/nuxtjs/realtime-avatar-stack.mdx
new file mode 100644
index 00000000000..1281107ea91
--- /dev/null
+++ b/apps/ui-library/content/docs/nuxtjs/realtime-avatar-stack.mdx
@@ -0,0 +1,49 @@
+---
+title: Realtime Avatar Stack
+description: Avatar stack in realtime
+---
+
+<BlockPreview name="realtime-avatar-stack-demo" />
+
+## Installation
+
+<BlockItem
+ name="realtime-avatar-stack-nuxtjs"
+ description="Renders a stack of avatars which are connected via Supabase Realtime"
+/>
+
+## Folder structure
+
+This block assumes that you have already installed a Supabase client for Nuxt from the previous step.
+
+<RegistryBlock itemName="realtime-avatar-stack-nuxtjs" />
+
+## Usage
+
+The `RealtimeAvatarStack` component renders stacked avatars which are connected to Supabase Realtime. It uses the Presence feature of Supabase Realtime. You can use this to show currently online users in a chatroom, game session or collaborative app.
+
+```html
+<script setup lang="ts">
+// Asumes you have Header component created
+import Header from '@/components/Header.vue'
+import RealtimeAvatarStack from '@/components/RealtimeAvatarStack.vue'
+</script>
+
+<template>
+ <Header class="flex items-center justify-between">
+ <h1>Lumon Industries</h1>
+ <RealtimeAvatarStack roomName="break_room" />
+ </Header>
+</template>
+```
+
+## Props
+
+| Prop | Type | Default | Description |
+| ---------- | -------- | ------- | ---------------------------------------------------- |
+| `roomName` | `string` | `null` | The name of the Supabase Realtime room to connect to |
+
+## Further reading
+
+- [Realtime Presence](https://supabase.com/docs/guides/realtime/presence)
+- [Realtime authorization](https://supabase.com/docs/guides/realtime/authorization)
diff --git a/apps/ui-library/content/docs/vue/current-user-avatar.mdx b/apps/ui-library/content/docs/vue/current-user-avatar.mdx
new file mode 100644
index 00000000000..280a6c05d0e
--- /dev/null
+++ b/apps/ui-library/content/docs/vue/current-user-avatar.mdx
@@ -0,0 +1,48 @@
+---
+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.
+
+```html
+<script setup lang="ts">
+// Asumes you have Header component created
+import Header from '@/components/Header.vue'
+import CurrentUserAvatar from '@/components/CurrentUserAvatar.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)
diff --git a/apps/ui-library/content/docs/vue/realtime-avatar-stack.mdx b/apps/ui-library/content/docs/vue/realtime-avatar-stack.mdx
new file mode 100644
index 00000000000..8ea06849e8d
--- /dev/null
+++ b/apps/ui-library/content/docs/vue/realtime-avatar-stack.mdx
@@ -0,0 +1,49 @@
+---
+title: Realtime Avatar Stack
+description: Avatar stack in realtime
+---
+
+<BlockPreview name="realtime-avatar-stack-demo" />
+
+## Installation
+
+<BlockItem
+ name="realtime-avatar-stack-vue"
+ description="Renders a stack of avatars which are connected via Supabase Realtime"
+/>
+
+## Folder structure
+
+This block assumes that you have already installed a Supabase client for Vue from the previous step.
+
+<RegistryBlock itemName="realtime-avatar-stack-vue" />
+
+## Usage
+
+The `RealtimeAvatarStack` component renders stacked avatars which are connected to Supabase Realtime. It uses the Presence feature of Supabase Realtime. You can use this to show currently online users in a chatroom, game session or collaborative app.
+
+```html
+<script setup lang="ts">
+// Asumes you have Header component created
+import Header from '@/components/Header.vue'
+import RealtimeAvatarStack from '@/components/RealtimeAvatarStack.vue'
+</script>
+
+<template>
+ <Header class="flex items-center justify-between">
+ <h1>Lumon Industries</h1>
+ <RealtimeAvatarStack roomName="break_room" />
+ </Header>
+</template>
+```
+
+## Props
+
+| Prop | Type | Default | Description |
+| ---------- | -------- | ------- | ---------------------------------------------------- |
+| `roomName` | `string` | `null` | The name of the Supabase Realtime room to connect to |
+
+## Further reading
+
+- [Realtime Presence](https://supabase.com/docs/guides/realtime/presence)
+- [Realtime authorization](https://supabase.com/docs/guides/realtime/authorization)
diff --git a/apps/ui-library/public/llms.txt b/apps/ui-library/public/llms.txt
index 02e7abd8fad..1b76808e7e7 100644
--- a/apps/ui-library/public/llms.txt
+++ b/apps/ui-library/public/llms.txt
@@ -1,5 +1,5 @@
# Supabase UI Library
-Last updated: 2026-01-22T19:37:07.586Z
+Last updated: 2026-02-20T06:13:03.281Z
## Overview
Library of components for your project. The components integrate with Supabase and are shadcn compatible.
@@ -33,10 +33,14 @@ Library of components for your project. The components integrate with Supabase a
- Social authentication block for Next.js
- [Supabase Client Libraries](https://supabase.com/ui/docs/nuxtjs/client)
- Supabase client for Nuxt.js
+- [Current User Avatar](https://supabase.com/ui/docs/nuxtjs/current-user-avatar)
+ - Supabase Auth-aware avatar
- [Dropzone (File Upload)](https://supabase.com/ui/docs/nuxtjs/dropzone)
- Displays a control for easier uploading of files directly to Supabase Storage
- [Password-based Authentication](https://supabase.com/ui/docs/nuxtjs/password-based-auth)
- Password-based authentication block for Nuxt.js
+- [Realtime Avatar Stack](https://supabase.com/ui/docs/nuxtjs/realtime-avatar-stack)
+ - Avatar stack in realtime
- [Realtime Cursor](https://supabase.com/ui/docs/nuxtjs/realtime-cursor)
- Real-time cursor sharing for collaborative applications
- [Social Authentication](https://supabase.com/ui/docs/nuxtjs/social-auth)
@@ -93,10 +97,14 @@ Library of components for your project. The components integrate with Supabase a
- Social authentication block for Tanstack Start
- [Supabase Client Libraries](https://supabase.com/ui/docs/vue/client)
- Supabase client for Vue Single Page Applications
+- [Current User Avatar](https://supabase.com/ui/docs/vue/current-user-avatar)
+ - Supabase Auth-aware avatar
- [Dropzone (File Upload)](https://supabase.com/ui/docs/vue/dropzone)
- Displays a control for easier uploading of files directly to Supabase Storage
- [Password-based Authentication](https://supabase.com/ui/docs/vue/password-based-auth)
- Password-based authentication block for Vue Single Page Applications
+- [Realtime Avatar Stack](https://supabase.com/ui/docs/vue/realtime-avatar-stack)
+ - Avatar stack in realtime
- [Realtime Cursor](https://supabase.com/ui/docs/vue/realtime-cursor)
- Real-time cursor sharing for collaborative applications
- [Social Authentication](https://supabase.com/ui/docs/vue/social-auth)
diff --git a/apps/ui-library/public/r/current-user-avatar-nuxtjs.json b/apps/ui-library/public/r/current-user-avatar-nuxtjs.json
new file mode 100644
index 00000000000..7d4908ffd18
--- /dev/null
+++ b/apps/ui-library/public/r/current-user-avatar-nuxtjs.json
@@ -0,0 +1,33 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "current-user-avatar-nuxtjs",
+ "type": "registry:block",
+ "title": "Current User Avatar",
+ "description": "Component which renders the current user's avatar.",
+ "dependencies": [
+ "@supabase/supabase-js@latest"
+ ],
+ "registryDependencies": [
+ "avatar"
+ ],
+ "files": [
+ {
+ "path": "registry/default/current-user-avatar/nuxtjs/app/components/current-user-avatar.vue",
+ "content": "<script setup lang=\"ts\">\nimport { computed } from 'vue'\n// @ts-ignore\nimport { useCurrentUserImage } from '@/composables/useCurrentUserImage'\n// @ts-ignore\nimport { useCurrentUserName } from '@/composables/useCurrentUserName'\n\nimport Avatar from '@/components/ui/avatar/Avatar.vue'\nimport AvatarFallback from '@/components/ui/avatar/AvatarFallback.vue'\nimport AvatarImage from '@/components/ui/avatar/AvatarImage.vue'\n\nconst { image: profileImage } = useCurrentUserImage()\nconst { name } = useCurrentUserName()\n\nconst initials = computed(() => {\n if (!name.value) return ''\n return name.value\n .split(' ')\n .map(word => word[0])\n .join('')\n .toUpperCase()\n})\n</script>\n\n<template>\n <Avatar>\n <AvatarImage\n v-if=\"profileImage\"\n :src=\"profileImage\"\n :alt=\"initials\"\n />\n <AvatarFallback>\n {{ initials }}\n </AvatarFallback>\n </Avatar>\n</template>\n",
+ "type": "registry:component",
+ "target": "app/components/current-user-avatar.vue"
+ },
+ {
+ "path": "registry/default/current-user-avatar/nuxtjs/app/composables/useCurrentUserName.ts",
+ "content": "import { ref, onMounted } from 'vue'\n// @ts-ignore\nimport { createClient } from \"@/lib/supabase/client\"\n\nexport function useCurrentUserName() {\n const name = ref<string | null>(null)\n\n const fetchProfileName = async () => {\n const { data, error } = await createClient().auth.getSession()\n\n if (error) {\n console.error(error)\n return\n }\n\n name.value = data.session?.user.user_metadata.full_name ?? '?'\n }\n\n onMounted(() => {\n fetchProfileName()\n })\n\n return {\n name,\n }\n}\n",
+ "type": "registry:component",
+ "target": "app/composables/useCurrentUserName.ts"
+ },
+ {
+ "path": "registry/default/current-user-avatar/nuxtjs/app/composables/useCurrentUserImage.ts",
+ "content": "import { ref, onMounted } from 'vue'\n// @ts-ignore\nimport { createClient } from \"@/lib/supabase/client\"\n\nexport function useCurrentUserImage() {\n const image = ref<string | null>(null)\n\n const fetchUserImage = async () => {\n const { data, error } = await createClient().auth.getSession()\n\n if (error) {\n console.error(error)\n return\n }\n\n image.value = data.session?.user.user_metadata.avatar_url ?? null\n }\n\n onMounted(() => {\n fetchUserImage()\n })\n\n return {\n image,\n }\n}\n",
+ "type": "registry:component",
+ "target": "app/composables/useCurrentUserImage.ts"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/apps/ui-library/public/r/current-user-avatar-vue.json b/apps/ui-library/public/r/current-user-avatar-vue.json
new file mode 100644
index 00000000000..b9e7dce2f3b
--- /dev/null
+++ b/apps/ui-library/public/r/current-user-avatar-vue.json
@@ -0,0 +1,33 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "current-user-avatar-vue",
+ "type": "registry:block",
+ "title": "Current User Avatar",
+ "description": "Component which renders the current user's avatar.",
+ "dependencies": [
+ "@supabase/supabase-js@latest"
+ ],
+ "registryDependencies": [
+ "avatar"
+ ],
+ "files": [
+ {
+ "path": "registry/default/current-user-avatar/vue/components/current-user-avatar.vue",
+ "content": "<script setup lang=\"ts\">\nimport { computed } from 'vue'\n// @ts-ignore\nimport { useCurrentUserImage } from '@/composables/useCurrentUserImage'\n// @ts-ignore\nimport { useCurrentUserName } from '@/composables/useCurrentUserName'\n\nimport Avatar from '@/components/ui/avatar/Avatar.vue'\nimport AvatarFallback from '@/components/ui/avatar/AvatarFallback.vue'\nimport AvatarImage from '@/components/ui/avatar/AvatarImage.vue'\n\nconst { image: profileImage } = useCurrentUserImage()\nconst { name } = useCurrentUserName()\n\nconst initials = computed(() => {\n if (!name.value) return ''\n return name.value\n .split(' ')\n .map(word => word[0])\n .join('')\n .toUpperCase()\n})\n</script>\n\n<template>\n <Avatar>\n <AvatarImage\n v-if=\"profileImage\"\n :src=\"profileImage\"\n :alt=\"initials\"\n />\n <AvatarFallback>\n {{ initials }}\n </AvatarFallback>\n </Avatar>\n</template>\n",
+ "type": "registry:component",
+ "target": "components/current-user-avatar.vue"
+ },
+ {
+ "path": "registry/default/current-user-avatar/vue/composables/useCurrentUserName.ts",
+ "content": "import { ref, onMounted } from 'vue'\n// @ts-ignore\nimport { createClient } from \"@/lib/supabase/client\"\n\nexport function useCurrentUserName() {\n const name = ref<string | null>(null)\n\n const fetchProfileName = async () => {\n const { data, error } = await createClient().auth.getSession()\n\n if (error) {\n console.error(error)\n return\n }\n\n name.value = data.session?.user.user_metadata.full_name ?? '?'\n }\n\n onMounted(() => {\n fetchProfileName()\n })\n\n return {\n name,\n }\n}\n",
+ "type": "registry:component",
+ "target": "composables/useCurrentUserName.ts"
+ },
+ {
+ "path": "registry/default/current-user-avatar/vue/composables/useCurrentUserImage.ts",
+ "content": "import { ref, onMounted } from 'vue'\n// @ts-ignore\nimport { createClient } from \"@/lib/supabase/client\"\n\nexport function useCurrentUserImage() {\n const image = ref<string | null>(null)\n\n const fetchUserImage = async () => {\n const { data, error } = await createClient().auth.getSession()\n\n if (error) {\n console.error(error)\n return\n }\n\n image.value = data.session?.user.user_metadata.avatar_url ?? null\n }\n\n onMounted(() => {\n fetchUserImage()\n })\n\n return {\n image,\n }\n}\n",
+ "type": "registry:component",
+ "target": "composables/useCurrentUserImage.ts"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/apps/ui-library/public/r/realtime-avatar-stack-nuxtjs.json b/apps/ui-library/public/r/realtime-avatar-stack-nuxtjs.json
new file mode 100644
index 00000000000..f30c2151e7a
--- /dev/null
+++ b/apps/ui-library/public/r/realtime-avatar-stack-nuxtjs.json
@@ -0,0 +1,46 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "realtime-avatar-stack-nuxtjs",
+ "type": "registry:block",
+ "title": "Realtime Avatar Stack",
+ "description": "Component which stack of avatars, tracked by realtime presence.",
+ "dependencies": [
+ "@supabase/supabase-js@latest"
+ ],
+ "registryDependencies": [
+ "avatar",
+ "tooltip"
+ ],
+ "files": [
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/components/realtime-avatar-stack.vue",
+ "content": "<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\n // @ts-ignore\nimport AvatarStack from '@/components/avatar-stack.vue'\nimport { useRealtimePresenceRoom } from '../composables/useRealtimePresenceRoom'\n\nconst props = defineProps<{\n roomName: string\n}>()\n\nconst { users: usersMap } = useRealtimePresenceRoom(props.roomName)\n\nconst avatars = computed(() =>\n Object.values(usersMap.value).map((user) => ({\n name: user.name,\n image: user.image,\n }))\n)\n</script>\n\n<template>\n <AvatarStack :avatars=\"avatars\" />\n</template>\n",
+ "type": "registry:component",
+ "target": "app/components/realtime-avatar-stack.vue"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/components/avatar-stack.vue",
+ "content": "<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport Avatar from '@/components/ui/avatar/Avatar.vue'\nimport AvatarImage from '@/components/ui/avatar/AvatarImage.vue'\nimport AvatarFallback from '@/components/ui/avatar/AvatarFallback.vue'\n\nimport Tooltip from '@/components/ui/tooltip/Tooltip.vue'\nimport TooltipContent from '@/components/ui/tooltip/TooltipContent.vue'\nimport TooltipTrigger from '@/components/ui/tooltip/TooltipTrigger.vue'\n\ninterface AvatarItem {\n name: string\n image: string\n}\n\nconst props = defineProps<{\n avatars: AvatarItem[]\n orientation?: 'vertical' | 'horizontal'\n maxAvatarsAmount?: number\n class?: string\n}>()\n\nconst orientation = computed(() => props.orientation ?? 'vertical')\nconst maxAvatarsAmount = computed(() => props.maxAvatarsAmount ?? 3)\n\nconst shownAvatars = computed(() =>\n props.avatars.slice(0, maxAvatarsAmount.value)\n)\n\nconst hiddenAvatars = computed(() =>\n props.avatars.slice(maxAvatarsAmount.value)\n)\n\nconst containerClasses = computed(() => [\n 'flex -space-x-4 -space-y-4',\n orientation.value === 'vertical' ? 'flex-row -space-y-0' : 'flex-col -space-x-0',\n props.class,\n])\n\nfunction getInitials(name: string) {\n return name\n ?.split(' ')\n ?.map(word => word[0])\n ?.join('')\n ?.toUpperCase()\n}\n</script>\n\n<template>\n <div :class=\"containerClasses\">\n <!-- Visible avatars -->\n <Tooltip\n v-for=\"({ name, image }, index) in shownAvatars\"\n :key=\"`${name}-${image}-${index}`\"\n >\n <TooltipTrigger>\n <Avatar class=\"hover:z-10\">\n <AvatarImage :src=\"image\" />\n <AvatarFallback>\n {{ getInitials(name) }}\n </AvatarFallback>\n </Avatar>\n </TooltipTrigger>\n\n <TooltipContent>\n <p>{{ name }}</p>\n </TooltipContent>\n </Tooltip>\n\n <!-- Hidden avatars -->\n <Tooltip v-if=\"hiddenAvatars.length\">\n <TooltipTrigger>\n <Avatar>\n <AvatarFallback>\n +{{ avatars.length - shownAvatars.length }}\n </AvatarFallback>\n </Avatar>\n </TooltipTrigger>\n\n <TooltipContent>\n <p\n v-for=\"({ name }, index) in hiddenAvatars\"\n :key=\"`${name}-${index}`\"\n >\n {{ name }}\n </p>\n </TooltipContent>\n </Tooltip>\n </div>\n</template>\n",
+ "type": "registry:component",
+ "target": "app/components/avatar-stack.vue"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/composables/useCurrentUserImage.ts",
+ "content": "import { ref, onMounted } from 'vue'\n// @ts-ignore\nimport { createClient } from \"@/lib/supabase/client\"\n\nexport function useCurrentUserImage() {\n const image = ref<string | null>(null)\n\n const fetchUserImage = async () => {\n const { data, error } = await createClient().auth.getSession()\n\n if (error) {\n console.error(error)\n return\n }\n\n image.value = data.session?.user.user_metadata.avatar_url ?? null\n }\n\n onMounted(() => {\n fetchUserImage()\n })\n\n return {\n image,\n }\n}\n",
+ "type": "registry:component",
+ "target": "app/composables/useCurrentUserImage.ts"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/composables/useCurrentUserName.ts",
+ "content": "import { ref, onMounted } from 'vue'\n// @ts-ignore\nimport { createClient } from \"@/lib/supabase/client\"\n\nexport function useCurrentUserName() {\n const name = ref<string | null>(null)\n\n const fetchProfileName = async () => {\n const { data, error } = await createClient().auth.getSession()\n\n if (error) {\n console.error(error)\n return\n }\n\n name.value = data.session?.user.user_metadata.full_name ?? '?'\n }\n\n onMounted(() => {\n fetchProfileName()\n })\n\n return {\n name,\n }\n}\n",
+ "type": "registry:component",
+ "target": "app/composables/useCurrentUserName.ts"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/composables/useRealtimePresenceRoom.ts",
+ "content": "import { ref, watch, onUnmounted } from 'vue'\nimport { REALTIME_SUBSCRIBE_STATES } from '@supabase/supabase-js'\n\nimport { useCurrentUserImage } from './useCurrentUserImage'\nimport { useCurrentUserName } from './useCurrentUserName'\n// @ts-ignore\nimport { createClient } from \"@/lib/supabase/client\"\n\nconst supabase = createClient()\n\nexport type RealtimeUser = {\n id: string\n name: string\n image: string\n}\n\nexport function useRealtimePresenceRoom(roomName: string) {\n const { image: currentUserImage } = useCurrentUserImage()\n const { name: currentUserName } = useCurrentUserName()\n\n const users = ref<Record<string, RealtimeUser>>({})\n\n let room: ReturnType<typeof supabase.channel> | null = null\n\n function setupRoom() {\n if (!roomName) return\n\n room = supabase.channel(roomName)\n\n room\n .on('presence', { event: 'sync' }, () => {\n const newState =\n room?.presenceState<{ image: string; name: string }>() ?? {}\n\n const newUsers = Object.fromEntries(\n Object.entries(newState).map(([key, values]) => {\n const typedValues = values as Array<{ image: string; name: string }>\n return [\n key,\n {\n id: key,\n name: typedValues[0].name,\n image: typedValues[0].image,\n },\n ]\n })\n ) as Record<string, RealtimeUser>\n\n users.value = newUsers\n })\n .subscribe(async (status: REALTIME_SUBSCRIBE_STATES) => {\n if (status === REALTIME_SUBSCRIBE_STATES.SUBSCRIBED && room) {\n await room.track({\n name: currentUserName.value,\n image: currentUserImage.value,\n })\n } else {\n users.value = {}\n }\n })\n }\n\n function cleanup() {\n if (room) {\n room.unsubscribe()\n room = null\n }\n }\n\n watch(\n [() => roomName, currentUserName, currentUserImage],\n () => {\n cleanup()\n setupRoom()\n },\n { immediate: true }\n )\n\n onUnmounted(() => {\n cleanup()\n })\n\n return { users }\n}\n",
+ "type": "registry:component",
+ "target": "app/composables/useRealtimePresenceRoom.ts"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/apps/ui-library/public/r/realtime-avatar-stack-vue.json b/apps/ui-library/public/r/realtime-avatar-stack-vue.json
new file mode 100644
index 00000000000..655c97194ca
--- /dev/null
+++ b/apps/ui-library/public/r/realtime-avatar-stack-vue.json
@@ -0,0 +1,46 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "realtime-avatar-stack-vue",
+ "type": "registry:block",
+ "title": "Realtime Avatar Stack",
+ "description": "Component which stack of avatars, tracked by realtime presence.",
+ "dependencies": [
+ "@supabase/supabase-js@latest"
+ ],
+ "registryDependencies": [
+ "avatar",
+ "tooltip"
+ ],
+ "files": [
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/components/realtime-avatar-stack.vue",
+ "content": "<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\n // @ts-ignore\nimport AvatarStack from '@/components/avatar-stack.vue'\nimport { useRealtimePresenceRoom } from '../composables/useRealtimePresenceRoom'\n\nconst props = defineProps<{\n roomName: string\n}>()\n\nconst { users: usersMap } = useRealtimePresenceRoom(props.roomName)\n\nconst avatars = computed(() =>\n Object.values(usersMap.value).map((user) => ({\n name: user.name,\n image: user.image,\n }))\n)\n</script>\n\n<template>\n <AvatarStack :avatars=\"avatars\" />\n</template>\n",
+ "type": "registry:component",
+ "target": "components/realtime-avatar-stack.vue"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/components/avatar-stack.vue",
+ "content": "<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport Avatar from '@/components/ui/avatar/Avatar.vue'\nimport AvatarImage from '@/components/ui/avatar/AvatarImage.vue'\nimport AvatarFallback from '@/components/ui/avatar/AvatarFallback.vue'\n\nimport Tooltip from '@/components/ui/tooltip/Tooltip.vue'\nimport TooltipContent from '@/components/ui/tooltip/TooltipContent.vue'\nimport TooltipTrigger from '@/components/ui/tooltip/TooltipTrigger.vue'\n\ninterface AvatarItem {\n name: string\n image: string\n}\n\nconst props = defineProps<{\n avatars: AvatarItem[]\n orientation?: 'vertical' | 'horizontal'\n maxAvatarsAmount?: number\n class?: string\n}>()\n\nconst orientation = computed(() => props.orientation ?? 'vertical')\nconst maxAvatarsAmount = computed(() => props.maxAvatarsAmount ?? 3)\n\nconst shownAvatars = computed(() =>\n props.avatars.slice(0, maxAvatarsAmount.value)\n)\n\nconst hiddenAvatars = computed(() =>\n props.avatars.slice(maxAvatarsAmount.value)\n)\n\nconst containerClasses = computed(() => [\n 'flex -space-x-4 -space-y-4',\n orientation.value === 'vertical' ? 'flex-row -space-y-0' : 'flex-col -space-x-0',\n props.class,\n])\n\nfunction getInitials(name: string) {\n return name\n ?.split(' ')\n ?.map(word => word[0])\n ?.join('')\n ?.toUpperCase()\n}\n</script>\n\n<template>\n <div :class=\"containerClasses\">\n <!-- Visible avatars -->\n <Tooltip\n v-for=\"({ name, image }, index) in shownAvatars\"\n :key=\"`${name}-${image}-${index}`\"\n >\n <TooltipTrigger>\n <Avatar class=\"hover:z-10\">\n <AvatarImage :src=\"image\" />\n <AvatarFallback>\n {{ getInitials(name) }}\n </AvatarFallback>\n </Avatar>\n </TooltipTrigger>\n\n <TooltipContent>\n <p>{{ name }}</p>\n </TooltipContent>\n </Tooltip>\n\n <!-- Hidden avatars -->\n <Tooltip v-if=\"hiddenAvatars.length\">\n <TooltipTrigger>\n <Avatar>\n <AvatarFallback>\n +{{ avatars.length - shownAvatars.length }}\n </AvatarFallback>\n </Avatar>\n </TooltipTrigger>\n\n <TooltipContent>\n <p\n v-for=\"({ name }, index) in hiddenAvatars\"\n :key=\"`${name}-${index}`\"\n >\n {{ name }}\n </p>\n </TooltipContent>\n </Tooltip>\n </div>\n</template>\n",
+ "type": "registry:component",
+ "target": "components/avatar-stack.vue"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/composables/useCurrentUserImage.ts",
+ "content": "import { ref, onMounted } from 'vue'\n// @ts-ignore\nimport { createClient } from \"@/lib/supabase/client\"\n\nexport function useCurrentUserImage() {\n const image = ref<string | null>(null)\n\n const fetchUserImage = async () => {\n const { data, error } = await createClient().auth.getSession()\n\n if (error) {\n console.error(error)\n return\n }\n\n image.value = data.session?.user.user_metadata.avatar_url ?? null\n }\n\n onMounted(() => {\n fetchUserImage()\n })\n\n return {\n image,\n }\n}\n",
+ "type": "registry:component",
+ "target": "composables/useCurrentUserImage.ts"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/composables/useCurrentUserName.ts",
+ "content": "import { ref, onMounted } from 'vue'\n// @ts-ignore\nimport { createClient } from \"@/lib/supabase/client\"\n\nexport function useCurrentUserName() {\n const name = ref<string | null>(null)\n\n const fetchProfileName = async () => {\n const { data, error } = await createClient().auth.getSession()\n\n if (error) {\n console.error(error)\n return\n }\n\n name.value = data.session?.user.user_metadata.full_name ?? '?'\n }\n\n onMounted(() => {\n fetchProfileName()\n })\n\n return {\n name,\n }\n}\n",
+ "type": "registry:component",
+ "target": "composables/useCurrentUserName.ts"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/composables/useRealtimePresenceRoom.ts",
+ "content": "import { ref, watch, onUnmounted } from 'vue'\nimport { REALTIME_SUBSCRIBE_STATES } from '@supabase/supabase-js'\n\nimport { useCurrentUserImage } from './useCurrentUserImage'\nimport { useCurrentUserName } from './useCurrentUserName'\n// @ts-ignore\nimport { createClient } from \"@/lib/supabase/client\"\n\nconst supabase = createClient()\n\nexport type RealtimeUser = {\n id: string\n name: string\n image: string\n}\n\nexport function useRealtimePresenceRoom(roomName: string) {\n const { image: currentUserImage } = useCurrentUserImage()\n const { name: currentUserName } = useCurrentUserName()\n\n const users = ref<Record<string, RealtimeUser>>({})\n\n let room: ReturnType<typeof supabase.channel> | null = null\n\n function setupRoom() {\n if (!roomName) return\n\n room = supabase.channel(roomName)\n\n room\n .on('presence', { event: 'sync' }, () => {\n const newState =\n room?.presenceState<{ image: string; name: string }>() ?? {}\n\n const newUsers = Object.fromEntries(\n Object.entries(newState).map(([key, values]) => {\n const typedValues = values as Array<{ image: string; name: string }>\n if (typedValues.length > 0) {\n return [\n key,\n {\n id: key,\n name: typedValues[0].name,\n image: typedValues[0].image,\n },\n ]\n } else {\n return [\n key,\n {\n id: key,\n name: '',\n image: '',\n },\n ]\n }\n })\n ) as Record<string, RealtimeUser>\n\n users.value = newUsers\n })\n .subscribe(async (status: REALTIME_SUBSCRIBE_STATES) => {\n if (status === REALTIME_SUBSCRIBE_STATES.SUBSCRIBED && room) {\n await room.track({\n name: currentUserName.value,\n image: currentUserImage.value,\n })\n } else {\n users.value = {}\n }\n })\n }\n\n function cleanup() {\n if (room) {\n room.unsubscribe()\n room = null\n }\n }\n\n watch(\n [() => roomName, currentUserName, currentUserImage],\n () => {\n cleanup()\n setupRoom()\n },\n { immediate: true }\n )\n\n onUnmounted(() => {\n cleanup()\n })\n\n return { users }\n}\n",
+ "type": "registry:component",
+ "target": "composables/useRealtimePresenceRoom.ts"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/apps/ui-library/public/r/registry.json b/apps/ui-library/public/r/registry.json
index 969636bc3a5..bb2b4b399e3 100644
--- a/apps/ui-library/public/r/registry.json
+++ b/apps/ui-library/public/r/registry.json
@@ -2117,6 +2117,144 @@
"lucide-vue-next"
]
},
+ {
+ "name": "current-user-avatar-nuxtjs",
+ "type": "registry:block",
+ "title": "Current User Avatar",
+ "description": "Component which renders the current user's avatar.",
+ "registryDependencies": [
+ "avatar"
+ ],
+ "files": [
+ {
+ "path": "registry/default/current-user-avatar/nuxtjs/app/components/current-user-avatar.vue",
+ "type": "registry:component",
+ "target": "app/components/current-user-avatar.vue"
+ },
+ {
+ "path": "registry/default/current-user-avatar/nuxtjs/app/composables/useCurrentUserName.ts",
+ "type": "registry:component",
+ "target": "app/composables/useCurrentUserName.ts"
+ },
+ {
+ "path": "registry/default/current-user-avatar/nuxtjs/app/composables/useCurrentUserImage.ts",
+ "type": "registry:component",
+ "target": "app/composables/useCurrentUserImage.ts"
+ }
+ ],
+ "dependencies": [
+ "@supabase/supabase-js@latest"
+ ]
+ },
+ {
+ "name": "current-user-avatar-vue",
+ "type": "registry:block",
+ "title": "Current User Avatar",
+ "description": "Component which renders the current user's avatar.",
+ "registryDependencies": [
+ "avatar"
+ ],
+ "files": [
+ {
+ "path": "registry/default/current-user-avatar/vue/components/current-user-avatar.vue",
+ "type": "registry:component",
+ "target": "components/current-user-avatar.vue"
+ },
+ {
+ "path": "registry/default/current-user-avatar/vue/composables/useCurrentUserName.ts",
+ "type": "registry:component",
+ "target": "composables/useCurrentUserName.ts"
+ },
+ {
+ "path": "registry/default/current-user-avatar/vue/composables/useCurrentUserImage.ts",
+ "type": "registry:component",
+ "target": "composables/useCurrentUserImage.ts"
+ }
+ ],
+ "dependencies": [
+ "@supabase/supabase-js@latest"
+ ]
+ },
+ {
+ "name": "realtime-avatar-stack-nuxtjs",
+ "type": "registry:block",
+ "title": "Realtime Avatar Stack",
+ "description": "Component which stack of avatars, tracked by realtime presence.",
+ "registryDependencies": [
+ "avatar",
+ "tooltip"
+ ],
+ "files": [
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/components/realtime-avatar-stack.vue",
+ "type": "registry:component",
+ "target": "app/components/realtime-avatar-stack.vue"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/components/avatar-stack.vue",
+ "type": "registry:component",
+ "target": "app/components/avatar-stack.vue"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/composables/useCurrentUserImage.ts",
+ "type": "registry:component",
+ "target": "app/composables/useCurrentUserImage.ts"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/composables/useCurrentUserName.ts",
+ "type": "registry:component",
+ "target": "app/composables/useCurrentUserName.ts"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/composables/useRealtimePresenceRoom.ts",
+ "type": "registry:component",
+ "target": "app/composables/useRealtimePresenceRoom.ts"
+ }
+ ],
+ "dependencies": [
+ "@supabase/supabase-js@latest"
+ ]
+ },
+ {
+ "name": "realtime-avatar-stack-vue",
+ "type": "registry:block",
+ "title": "Realtime Avatar Stack",
+ "description": "Component which stack of avatars, tracked by realtime presence.",
+ "registryDependencies": [
+ "avatar",
+ "tooltip"
+ ],
+ "files": [
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/components/realtime-avatar-stack.vue",
+ "type": "registry:component",
+ "target": "components/realtime-avatar-stack.vue"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/components/avatar-stack.vue",
+ "type": "registry:component",
+ "target": "components/avatar-stack.vue"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/composables/useCurrentUserImage.ts",
+ "type": "registry:component",
+ "target": "composables/useCurrentUserImage.ts"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/composables/useCurrentUserName.ts",
+ "type": "registry:component",
+ "target": "composables/useCurrentUserName.ts"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/composables/useRealtimePresenceRoom.ts",
+ "type": "registry:component",
+ "target": "composables/useRealtimePresenceRoom.ts"
+ }
+ ],
+ "dependencies": [
+ "@supabase/supabase-js@latest"
+ ]
+ },
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "ai-editor-rules",
diff --git a/blocks/vue/registry/current-user-avatar.ts b/blocks/vue/registry/current-user-avatar.ts
new file mode 100644
index 00000000000..09a7d3132cf
--- /dev/null
+++ b/blocks/vue/registry/current-user-avatar.ts
@@ -0,0 +1,6 @@
+import { type RegistryItem } from 'shadcn/schema'
+
+import nuxtjs from './default/current-user-avatar/nuxtjs/registry-item.json' with { type: 'json' }
+import vue from './default/current-user-avatar/vue/registry-item.json' with { type: 'json' }
+
+export const currentUserAvatar = [nuxtjs, vue] as RegistryItem[]
\ No newline at end of file
diff --git a/blocks/vue/registry/default/components/ui/avatar/Avatar.vue b/blocks/vue/registry/default/components/ui/avatar/Avatar.vue
new file mode 100644
index 00000000000..b82c6265b97
--- /dev/null
+++ b/blocks/vue/registry/default/components/ui/avatar/Avatar.vue
@@ -0,0 +1,16 @@
+<script setup lang="ts">
+defineProps<{
+ class?: string
+}>()
+</script>
+
+<template>
+ <div
+ :class="[
+ 'relative flex h-12 w-12 shrink-0 overflow-hidden rounded-full',
+ $props.class,
+ ]"
+ >
+ <slot />
+ </div>
+</template>
diff --git a/blocks/vue/registry/default/components/ui/avatar/AvatarFallback.vue b/blocks/vue/registry/default/components/ui/avatar/AvatarFallback.vue
new file mode 100644
index 00000000000..bcc4251dafd
--- /dev/null
+++ b/blocks/vue/registry/default/components/ui/avatar/AvatarFallback.vue
@@ -0,0 +1,16 @@
+<script setup lang="ts">
+defineProps<{
+ class?: string
+}>()
+</script>
+
+<template>
+ <div
+ :class="[
+ 'flex h-full w-full items-center justify-center rounded-full bg-muted',
+ $props.class,
+ ]"
+ >
+ <slot />
+ </div>
+</template>
\ No newline at end of file
diff --git a/blocks/vue/registry/default/components/ui/avatar/AvatarImage.vue b/blocks/vue/registry/default/components/ui/avatar/AvatarImage.vue
new file mode 100644
index 00000000000..bf7dc848edf
--- /dev/null
+++ b/blocks/vue/registry/default/components/ui/avatar/AvatarImage.vue
@@ -0,0 +1,15 @@
+<script setup lang="ts">
+defineProps<{
+ src: string
+ alt?: string
+ class?: string
+}>()
+</script>
+
+<template>
+ <img
+ :src="src"
+ :alt="alt || ''"
+ :class="['aspect-square h-full w-full', $props.class]"
+ />
+</template>
diff --git a/blocks/vue/registry/default/components/ui/tooltip/Tooltip.vue b/blocks/vue/registry/default/components/ui/tooltip/Tooltip.vue
new file mode 100644
index 00000000000..712dc4cab9b
--- /dev/null
+++ b/blocks/vue/registry/default/components/ui/tooltip/Tooltip.vue
@@ -0,0 +1,11 @@
+<script setup lang="ts">
+import { provide, ref } from 'vue'
+
+const open = ref(false)
+
+provide('tooltipOpen', open)
+</script>
+
+<template>
+ <slot />
+</template>
diff --git a/blocks/vue/registry/default/components/ui/tooltip/TooltipContent.vue b/blocks/vue/registry/default/components/ui/tooltip/TooltipContent.vue
new file mode 100644
index 00000000000..281346edcb6
--- /dev/null
+++ b/blocks/vue/registry/default/components/ui/tooltip/TooltipContent.vue
@@ -0,0 +1,62 @@
+<script setup lang="ts">
+import { inject, computed, Ref } from 'vue'
+
+const props = defineProps<{
+ side?: 'top' | 'bottom' | 'left' | 'right'
+ sideOffset?: number
+ class?: string
+}>()
+
+const open = inject<Ref<boolean>>('tooltipOpen')
+
+const positionClasses = computed(() => {
+ const offset = props.sideOffset ?? 2
+ switch (props.side) {
+ case 'top':
+ return 'bottom-full mb-2'
+ case 'bottom':
+ return 'top-full mt-2'
+ case 'left':
+ return 'right-full mr-2'
+ case 'right':
+ return 'left-full ml-2'
+ default:
+ return 'top-full mt-2'
+ }
+})
+
+const positionStyle = computed(() => {
+ const offset = props.sideOffset ?? 4
+ const allowedOffsets = [2, 4, 8]
+ if (allowedOffsets.includes(offset)) return {}
+ switch (props.side) {
+ case 'top':
+ return { marginBottom: `${offset}px` }
+ case 'bottom':
+ return { marginTop: `${offset}px` }
+ case 'left':
+ return { marginRight: `${offset}px` }
+ case 'right':
+ return { marginLeft: `${offset}px` }
+ default:
+ return { marginTop: `${offset}px` }
+ }
+})
+</script>
+
+<template>
+ <Teleport to="body">
+ <div
+ v-if="open"
+ :class="[
+ 'z-50 absolute rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground',
+ 'animate-in fade-in-0 zoom-in-95',
+ positionClasses,
+ props.class,
+ ]"
+ :style="positionStyle"
+ >
+ <slot />
+ </div>
+ </Teleport>
+</template>
diff --git a/blocks/vue/registry/default/components/ui/tooltip/TooltipProvider.vue b/blocks/vue/registry/default/components/ui/tooltip/TooltipProvider.vue
new file mode 100644
index 00000000000..f0662da8aa0
--- /dev/null
+++ b/blocks/vue/registry/default/components/ui/tooltip/TooltipProvider.vue
@@ -0,0 +1,11 @@
+<script setup lang="ts">
+import { provide, ref } from 'vue'
+
+const delayDuration = ref(0)
+
+provide('tooltipDelay', delayDuration)
+</script>
+
+<template>
+ <slot />
+</template>
diff --git a/blocks/vue/registry/default/components/ui/tooltip/TooltipTrigger.vue b/blocks/vue/registry/default/components/ui/tooltip/TooltipTrigger.vue
new file mode 100644
index 00000000000..32ff3669125
--- /dev/null
+++ b/blocks/vue/registry/default/components/ui/tooltip/TooltipTrigger.vue
@@ -0,0 +1,19 @@
+<script setup lang="ts">
+import { inject, Ref } from 'vue'
+
+const open = inject<Ref<boolean>>('tooltipOpen')
+
+function show() {
+ open.value = true
+}
+
+function hide() {
+ open.value = false
+}
+</script>
+
+<template>
+ <span @mouseenter="show" @mouseleave="hide">
+ <slot />
+ </span>
+</template>
diff --git a/blocks/vue/registry/default/current-user-avatar/nuxtjs/app/components/current-user-avatar.vue b/blocks/vue/registry/default/current-user-avatar/nuxtjs/app/components/current-user-avatar.vue
new file mode 100644
index 00000000000..04ad2a12278
--- /dev/null
+++ b/blocks/vue/registry/default/current-user-avatar/nuxtjs/app/components/current-user-avatar.vue
@@ -0,0 +1,36 @@
+<script setup lang="ts">
+import { computed } from 'vue'
+// @ts-ignore
+import { useCurrentUserImage } from '@/composables/useCurrentUserImage'
+// @ts-ignore
+import { useCurrentUserName } from '@/composables/useCurrentUserName'
+
+import Avatar from '@/components/ui/avatar/Avatar.vue'
+import AvatarFallback from '@/components/ui/avatar/AvatarFallback.vue'
+import AvatarImage from '@/components/ui/avatar/AvatarImage.vue'
+
+const { image: profileImage } = useCurrentUserImage()
+const { name } = useCurrentUserName()
+
+const initials = computed(() => {
+ if (!name.value) return ''
+ return name.value
+ .split(' ')
+ .map(word => word[0])
+ .join('')
+ .toUpperCase()
+})
+</script>
+
+<template>
+ <Avatar>
+ <AvatarImage
+ v-if="profileImage"
+ :src="profileImage"
+ :alt="initials"
+ />
+ <AvatarFallback>
+ {{ initials }}
+ </AvatarFallback>
+ </Avatar>
+</template>
diff --git a/blocks/vue/registry/default/current-user-avatar/nuxtjs/app/composables/useCurrentUserImage.ts b/blocks/vue/registry/default/current-user-avatar/nuxtjs/app/composables/useCurrentUserImage.ts
new file mode 100644
index 00000000000..4bb0f2c112c
--- /dev/null
+++ b/blocks/vue/registry/default/current-user-avatar/nuxtjs/app/composables/useCurrentUserImage.ts
@@ -0,0 +1,26 @@
+import { ref, onMounted } from 'vue'
+// @ts-ignore
+import { createClient } from "@/lib/supabase/client"
+
+export function useCurrentUserImage() {
+ const image = ref<string | null>(null)
+
+ const fetchUserImage = async () => {
+ const { data, error } = await createClient().auth.getSession()
+
+ if (error) {
+ console.error(error)
+ return
+ }
+
+ image.value = data.session?.user.user_metadata.avatar_url ?? null
+ }
+
+ onMounted(() => {
+ fetchUserImage()
+ })
+
+ return {
+ image,
+ }
+}
diff --git a/blocks/vue/registry/default/current-user-avatar/nuxtjs/app/composables/useCurrentUserName.ts b/blocks/vue/registry/default/current-user-avatar/nuxtjs/app/composables/useCurrentUserName.ts
new file mode 100644
index 00000000000..98c29cac39f
--- /dev/null
+++ b/blocks/vue/registry/default/current-user-avatar/nuxtjs/app/composables/useCurrentUserName.ts
@@ -0,0 +1,26 @@
+import { ref, onMounted } from 'vue'
+// @ts-ignore
+import { createClient } from "@/lib/supabase/client"
+
+export function useCurrentUserName() {
+ const name = ref<string | null>(null)
+
+ const fetchProfileName = async () => {
+ const { data, error } = await createClient().auth.getSession()
+
+ if (error) {
+ console.error(error)
+ return
+ }
+
+ name.value = data.session?.user.user_metadata.full_name ?? '?'
+ }
+
+ onMounted(() => {
+ fetchProfileName()
+ })
+
+ return {
+ name,
+ }
+}
diff --git a/blocks/vue/registry/default/current-user-avatar/nuxtjs/registry-item.json b/blocks/vue/registry/default/current-user-avatar/nuxtjs/registry-item.json
new file mode 100644
index 00000000000..4f4aa89e24d
--- /dev/null
+++ b/blocks/vue/registry/default/current-user-avatar/nuxtjs/registry-item.json
@@ -0,0 +1,25 @@
+{
+ "name": "current-user-avatar-nuxtjs",
+ "type": "registry:block",
+ "title": "Current User Avatar",
+ "description": "Component which renders the current user's avatar.",
+ "registryDependencies": ["avatar"],
+ "files": [
+ {
+ "path": "registry/default/current-user-avatar/nuxtjs/app/components/current-user-avatar.vue",
+ "type": "registry:component",
+ "target": "app/components/current-user-avatar.vue"
+ },
+ {
+ "path": "registry/default/current-user-avatar/nuxtjs/app/composables/useCurrentUserName.ts",
+ "type": "registry:component",
+ "target": "app/composables/useCurrentUserName.ts"
+ },
+ {
+ "path": "registry/default/current-user-avatar/nuxtjs/app/composables/useCurrentUserImage.ts",
+ "type": "registry:component",
+ "target": "app/composables/useCurrentUserImage.ts"
+ }
+ ],
+ "dependencies": ["@supabase/supabase-js@latest"]
+}
\ No newline at end of file
diff --git a/blocks/vue/registry/default/current-user-avatar/vue/components/current-user-avatar.vue b/blocks/vue/registry/default/current-user-avatar/vue/components/current-user-avatar.vue
new file mode 100644
index 00000000000..04ad2a12278
--- /dev/null
+++ b/blocks/vue/registry/default/current-user-avatar/vue/components/current-user-avatar.vue
@@ -0,0 +1,36 @@
+<script setup lang="ts">
+import { computed } from 'vue'
+// @ts-ignore
+import { useCurrentUserImage } from '@/composables/useCurrentUserImage'
+// @ts-ignore
+import { useCurrentUserName } from '@/composables/useCurrentUserName'
+
+import Avatar from '@/components/ui/avatar/Avatar.vue'
+import AvatarFallback from '@/components/ui/avatar/AvatarFallback.vue'
+import AvatarImage from '@/components/ui/avatar/AvatarImage.vue'
+
+const { image: profileImage } = useCurrentUserImage()
+const { name } = useCurrentUserName()
+
+const initials = computed(() => {
+ if (!name.value) return ''
+ return name.value
+ .split(' ')
+ .map(word => word[0])
+ .join('')
+ .toUpperCase()
+})
+</script>
+
+<template>
+ <Avatar>
+ <AvatarImage
+ v-if="profileImage"
+ :src="profileImage"
+ :alt="initials"
+ />
+ <AvatarFallback>
+ {{ initials }}
+ </AvatarFallback>
+ </Avatar>
+</template>
diff --git a/blocks/vue/registry/default/current-user-avatar/vue/composables/useCurrentUserImage.ts b/blocks/vue/registry/default/current-user-avatar/vue/composables/useCurrentUserImage.ts
new file mode 100644
index 00000000000..4bb0f2c112c
--- /dev/null
+++ b/blocks/vue/registry/default/current-user-avatar/vue/composables/useCurrentUserImage.ts
@@ -0,0 +1,26 @@
+import { ref, onMounted } from 'vue'
+// @ts-ignore
+import { createClient } from "@/lib/supabase/client"
+
+export function useCurrentUserImage() {
+ const image = ref<string | null>(null)
+
+ const fetchUserImage = async () => {
+ const { data, error } = await createClient().auth.getSession()
+
+ if (error) {
+ console.error(error)
+ return
+ }
+
+ image.value = data.session?.user.user_metadata.avatar_url ?? null
+ }
+
+ onMounted(() => {
+ fetchUserImage()
+ })
+
+ return {
+ image,
+ }
+}
diff --git a/blocks/vue/registry/default/current-user-avatar/vue/composables/useCurrentUserName.ts b/blocks/vue/registry/default/current-user-avatar/vue/composables/useCurrentUserName.ts
new file mode 100644
index 00000000000..98c29cac39f
--- /dev/null
+++ b/blocks/vue/registry/default/current-user-avatar/vue/composables/useCurrentUserName.ts
@@ -0,0 +1,26 @@
+import { ref, onMounted } from 'vue'
+// @ts-ignore
+import { createClient } from "@/lib/supabase/client"
+
+export function useCurrentUserName() {
+ const name = ref<string | null>(null)
+
+ const fetchProfileName = async () => {
+ const { data, error } = await createClient().auth.getSession()
+
+ if (error) {
+ console.error(error)
+ return
+ }
+
+ name.value = data.session?.user.user_metadata.full_name ?? '?'
+ }
+
+ onMounted(() => {
+ fetchProfileName()
+ })
+
+ return {
+ name,
+ }
+}
diff --git a/blocks/vue/registry/default/current-user-avatar/vue/registry-item.json b/blocks/vue/registry/default/current-user-avatar/vue/registry-item.json
new file mode 100644
index 00000000000..1aea8149730
--- /dev/null
+++ b/blocks/vue/registry/default/current-user-avatar/vue/registry-item.json
@@ -0,0 +1,25 @@
+{
+ "name": "current-user-avatar-vue",
+ "type": "registry:block",
+ "title": "Current User Avatar",
+ "description": "Component which renders the current user's avatar.",
+ "registryDependencies": ["avatar"],
+ "files": [
+ {
+ "path": "registry/default/current-user-avatar/vue/components/current-user-avatar.vue",
+ "type": "registry:component",
+ "target": "components/current-user-avatar.vue"
+ },
+ {
+ "path": "registry/default/current-user-avatar/vue/composables/useCurrentUserName.ts",
+ "type": "registry:component",
+ "target": "composables/useCurrentUserName.ts"
+ },
+ {
+ "path": "registry/default/current-user-avatar/vue/composables/useCurrentUserImage.ts",
+ "type": "registry:component",
+ "target": "composables/useCurrentUserImage.ts"
+ }
+ ],
+ "dependencies": ["@supabase/supabase-js@latest"]
+}
\ No newline at end of file
diff --git a/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/components/avatar-stack.vue b/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/components/avatar-stack.vue
new file mode 100644
index 00000000000..6d7e4ce1c79
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/components/avatar-stack.vue
@@ -0,0 +1,91 @@
+<script setup lang="ts">
+import { computed } from 'vue'
+
+import Avatar from '@/components/ui/avatar/Avatar.vue'
+import AvatarImage from '@/components/ui/avatar/AvatarImage.vue'
+import AvatarFallback from '@/components/ui/avatar/AvatarFallback.vue'
+
+import Tooltip from '@/components/ui/tooltip/Tooltip.vue'
+import TooltipContent from '@/components/ui/tooltip/TooltipContent.vue'
+import TooltipTrigger from '@/components/ui/tooltip/TooltipTrigger.vue'
+
+interface AvatarItem {
+ name: string
+ image: string
+}
+
+const props = defineProps<{
+ avatars: AvatarItem[]
+ orientation?: 'vertical' | 'horizontal'
+ maxAvatarsAmount?: number
+ class?: string
+}>()
+
+const orientation = computed(() => props.orientation ?? 'vertical')
+const maxAvatarsAmount = computed(() => props.maxAvatarsAmount ?? 3)
+
+const shownAvatars = computed(() =>
+ props.avatars.slice(0, maxAvatarsAmount.value)
+)
+
+const hiddenAvatars = computed(() =>
+ props.avatars.slice(maxAvatarsAmount.value)
+)
+
+const containerClasses = computed(() => [
+ 'flex -space-x-4 -space-y-4',
+ orientation.value === 'vertical' ? 'flex-row -space-y-0' : 'flex-col -space-x-0',
+ props.class,
+])
+
+function getInitials(name: string) {
+ return name
+ ?.split(' ')
+ ?.map(word => word[0])
+ ?.join('')
+ ?.toUpperCase()
+}
+</script>
+
+<template>
+ <div :class="containerClasses">
+ <!-- Visible avatars -->
+ <Tooltip
+ v-for="({ name, image }, index) in shownAvatars"
+ :key="`${name}-${image}-${index}`"
+ >
+ <TooltipTrigger>
+ <Avatar class="hover:z-10">
+ <AvatarImage :src="image" />
+ <AvatarFallback>
+ {{ getInitials(name) }}
+ </AvatarFallback>
+ </Avatar>
+ </TooltipTrigger>
+
+ <TooltipContent>
+ <p>{{ name }}</p>
+ </TooltipContent>
+ </Tooltip>
+
+ <!-- Hidden avatars -->
+ <Tooltip v-if="hiddenAvatars.length">
+ <TooltipTrigger>
+ <Avatar>
+ <AvatarFallback>
+ +{{ avatars.length - shownAvatars.length }}
+ </AvatarFallback>
+ </Avatar>
+ </TooltipTrigger>
+
+ <TooltipContent>
+ <p
+ v-for="({ name }, index) in hiddenAvatars"
+ :key="`${name}-${index}`"
+ >
+ {{ name }}
+ </p>
+ </TooltipContent>
+ </Tooltip>
+ </div>
+</template>
diff --git a/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/components/realtime-avatar-stack.vue b/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/components/realtime-avatar-stack.vue
new file mode 100644
index 00000000000..7cebf6512a5
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/components/realtime-avatar-stack.vue
@@ -0,0 +1,24 @@
+<script setup lang="ts">
+import { computed } from 'vue'
+
+ // @ts-ignore
+import AvatarStack from '@/components/avatar-stack.vue'
+import { useRealtimePresenceRoom } from '../composables/useRealtimePresenceRoom'
+
+const props = defineProps<{
+ roomName: string
+}>()
+
+const { users: usersMap } = useRealtimePresenceRoom(props.roomName)
+
+const avatars = computed(() =>
+ Object.values(usersMap.value).map((user) => ({
+ name: user.name,
+ image: user.image,
+ }))
+)
+</script>
+
+<template>
+ <AvatarStack :avatars="avatars" />
+</template>
diff --git a/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/composables/useCurrentUserImage.ts b/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/composables/useCurrentUserImage.ts
new file mode 100644
index 00000000000..4bb0f2c112c
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/composables/useCurrentUserImage.ts
@@ -0,0 +1,26 @@
+import { ref, onMounted } from 'vue'
+// @ts-ignore
+import { createClient } from "@/lib/supabase/client"
+
+export function useCurrentUserImage() {
+ const image = ref<string | null>(null)
+
+ const fetchUserImage = async () => {
+ const { data, error } = await createClient().auth.getSession()
+
+ if (error) {
+ console.error(error)
+ return
+ }
+
+ image.value = data.session?.user.user_metadata.avatar_url ?? null
+ }
+
+ onMounted(() => {
+ fetchUserImage()
+ })
+
+ return {
+ image,
+ }
+}
diff --git a/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/composables/useCurrentUserName.ts b/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/composables/useCurrentUserName.ts
new file mode 100644
index 00000000000..98c29cac39f
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/composables/useCurrentUserName.ts
@@ -0,0 +1,26 @@
+import { ref, onMounted } from 'vue'
+// @ts-ignore
+import { createClient } from "@/lib/supabase/client"
+
+export function useCurrentUserName() {
+ const name = ref<string | null>(null)
+
+ const fetchProfileName = async () => {
+ const { data, error } = await createClient().auth.getSession()
+
+ if (error) {
+ console.error(error)
+ return
+ }
+
+ name.value = data.session?.user.user_metadata.full_name ?? '?'
+ }
+
+ onMounted(() => {
+ fetchProfileName()
+ })
+
+ return {
+ name,
+ }
+}
diff --git a/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/composables/useRealtimePresenceRoom.ts b/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/composables/useRealtimePresenceRoom.ts
new file mode 100644
index 00000000000..a9b073b4961
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/app/composables/useRealtimePresenceRoom.ts
@@ -0,0 +1,84 @@
+import { ref, watch, onUnmounted } from 'vue'
+import { REALTIME_SUBSCRIBE_STATES } from '@supabase/supabase-js'
+
+import { useCurrentUserImage } from './useCurrentUserImage'
+import { useCurrentUserName } from './useCurrentUserName'
+// @ts-ignore
+import { createClient } from "@/lib/supabase/client"
+
+const supabase = createClient()
+
+export type RealtimeUser = {
+ id: string
+ name: string
+ image: string
+}
+
+export function useRealtimePresenceRoom(roomName: string) {
+ const { image: currentUserImage } = useCurrentUserImage()
+ const { name: currentUserName } = useCurrentUserName()
+
+ const users = ref<Record<string, RealtimeUser>>({})
+
+ let room: ReturnType<typeof supabase.channel> | null = null
+
+ function setupRoom() {
+ if (!roomName) return
+
+ room = supabase.channel(roomName)
+
+ room
+ .on('presence', { event: 'sync' }, () => {
+ const newState =
+ room?.presenceState<{ image: string; name: string }>() ?? {}
+
+ const newUsers = Object.fromEntries(
+ Object.entries(newState).map(([key, values]) => {
+ const typedValues = values as Array<{ image: string; name: string }>
+ return [
+ key,
+ {
+ id: key,
+ name: typedValues[0].name,
+ image: typedValues[0].image,
+ },
+ ]
+ })
+ ) as Record<string, RealtimeUser>
+
+ users.value = newUsers
+ })
+ .subscribe(async (status: REALTIME_SUBSCRIBE_STATES) => {
+ if (status === REALTIME_SUBSCRIBE_STATES.SUBSCRIBED && room) {
+ await room.track({
+ name: currentUserName.value,
+ image: currentUserImage.value,
+ })
+ } else {
+ users.value = {}
+ }
+ })
+ }
+
+ function cleanup() {
+ if (room) {
+ room.unsubscribe()
+ room = null
+ }
+ }
+
+ watch(
+ [() => roomName, currentUserName, currentUserImage],
+ () => {
+ cleanup()
+ setupRoom()
+ },
+ { immediate: true }
+ )
+
+ onUnmounted(() => {
+ cleanup()
+ })
+
+ return { users }
+}
diff --git a/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/registry-item.json b/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/registry-item.json
new file mode 100644
index 00000000000..2a20c7e4058
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-avatar-stack/nuxtjs/registry-item.json
@@ -0,0 +1,35 @@
+{
+ "name": "realtime-avatar-stack-nuxtjs",
+ "type": "registry:block",
+ "title": "Realtime Avatar Stack",
+ "description": "Component which stack of avatars, tracked by realtime presence.",
+ "registryDependencies": ["avatar", "tooltip"],
+ "files": [
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/components/realtime-avatar-stack.vue",
+ "type": "registry:component",
+ "target": "app/components/realtime-avatar-stack.vue"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/components/avatar-stack.vue",
+ "type": "registry:component",
+ "target": "app/components/avatar-stack.vue"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/composables/useCurrentUserImage.ts",
+ "type": "registry:component",
+ "target": "app/composables/useCurrentUserImage.ts"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/composables/useCurrentUserName.ts",
+ "type": "registry:component",
+ "target": "app/composables/useCurrentUserName.ts"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/nuxtjs/app/composables/useRealtimePresenceRoom.ts",
+ "type": "registry:component",
+ "target": "app/composables/useRealtimePresenceRoom.ts"
+ }
+ ],
+ "dependencies": ["@supabase/supabase-js@latest"]
+}
\ No newline at end of file
diff --git a/blocks/vue/registry/default/realtime-avatar-stack/vue/components/avatar-stack.vue b/blocks/vue/registry/default/realtime-avatar-stack/vue/components/avatar-stack.vue
new file mode 100644
index 00000000000..6d7e4ce1c79
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-avatar-stack/vue/components/avatar-stack.vue
@@ -0,0 +1,91 @@
+<script setup lang="ts">
+import { computed } from 'vue'
+
+import Avatar from '@/components/ui/avatar/Avatar.vue'
+import AvatarImage from '@/components/ui/avatar/AvatarImage.vue'
+import AvatarFallback from '@/components/ui/avatar/AvatarFallback.vue'
+
+import Tooltip from '@/components/ui/tooltip/Tooltip.vue'
+import TooltipContent from '@/components/ui/tooltip/TooltipContent.vue'
+import TooltipTrigger from '@/components/ui/tooltip/TooltipTrigger.vue'
+
+interface AvatarItem {
+ name: string
+ image: string
+}
+
+const props = defineProps<{
+ avatars: AvatarItem[]
+ orientation?: 'vertical' | 'horizontal'
+ maxAvatarsAmount?: number
+ class?: string
+}>()
+
+const orientation = computed(() => props.orientation ?? 'vertical')
+const maxAvatarsAmount = computed(() => props.maxAvatarsAmount ?? 3)
+
+const shownAvatars = computed(() =>
+ props.avatars.slice(0, maxAvatarsAmount.value)
+)
+
+const hiddenAvatars = computed(() =>
+ props.avatars.slice(maxAvatarsAmount.value)
+)
+
+const containerClasses = computed(() => [
+ 'flex -space-x-4 -space-y-4',
+ orientation.value === 'vertical' ? 'flex-row -space-y-0' : 'flex-col -space-x-0',
+ props.class,
+])
+
+function getInitials(name: string) {
+ return name
+ ?.split(' ')
+ ?.map(word => word[0])
+ ?.join('')
+ ?.toUpperCase()
+}
+</script>
+
+<template>
+ <div :class="containerClasses">
+ <!-- Visible avatars -->
+ <Tooltip
+ v-for="({ name, image }, index) in shownAvatars"
+ :key="`${name}-${image}-${index}`"
+ >
+ <TooltipTrigger>
+ <Avatar class="hover:z-10">
+ <AvatarImage :src="image" />
+ <AvatarFallback>
+ {{ getInitials(name) }}
+ </AvatarFallback>
+ </Avatar>
+ </TooltipTrigger>
+
+ <TooltipContent>
+ <p>{{ name }}</p>
+ </TooltipContent>
+ </Tooltip>
+
+ <!-- Hidden avatars -->
+ <Tooltip v-if="hiddenAvatars.length">
+ <TooltipTrigger>
+ <Avatar>
+ <AvatarFallback>
+ +{{ avatars.length - shownAvatars.length }}
+ </AvatarFallback>
+ </Avatar>
+ </TooltipTrigger>
+
+ <TooltipContent>
+ <p
+ v-for="({ name }, index) in hiddenAvatars"
+ :key="`${name}-${index}`"
+ >
+ {{ name }}
+ </p>
+ </TooltipContent>
+ </Tooltip>
+ </div>
+</template>
diff --git a/blocks/vue/registry/default/realtime-avatar-stack/vue/components/realtime-avatar-stack.vue b/blocks/vue/registry/default/realtime-avatar-stack/vue/components/realtime-avatar-stack.vue
new file mode 100644
index 00000000000..7cebf6512a5
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-avatar-stack/vue/components/realtime-avatar-stack.vue
@@ -0,0 +1,24 @@
+<script setup lang="ts">
+import { computed } from 'vue'
+
+ // @ts-ignore
+import AvatarStack from '@/components/avatar-stack.vue'
+import { useRealtimePresenceRoom } from '../composables/useRealtimePresenceRoom'
+
+const props = defineProps<{
+ roomName: string
+}>()
+
+const { users: usersMap } = useRealtimePresenceRoom(props.roomName)
+
+const avatars = computed(() =>
+ Object.values(usersMap.value).map((user) => ({
+ name: user.name,
+ image: user.image,
+ }))
+)
+</script>
+
+<template>
+ <AvatarStack :avatars="avatars" />
+</template>
diff --git a/blocks/vue/registry/default/realtime-avatar-stack/vue/composables/useCurrentUserImage.ts b/blocks/vue/registry/default/realtime-avatar-stack/vue/composables/useCurrentUserImage.ts
new file mode 100644
index 00000000000..4bb0f2c112c
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-avatar-stack/vue/composables/useCurrentUserImage.ts
@@ -0,0 +1,26 @@
+import { ref, onMounted } from 'vue'
+// @ts-ignore
+import { createClient } from "@/lib/supabase/client"
+
+export function useCurrentUserImage() {
+ const image = ref<string | null>(null)
+
+ const fetchUserImage = async () => {
+ const { data, error } = await createClient().auth.getSession()
+
+ if (error) {
+ console.error(error)
+ return
+ }
+
+ image.value = data.session?.user.user_metadata.avatar_url ?? null
+ }
+
+ onMounted(() => {
+ fetchUserImage()
+ })
+
+ return {
+ image,
+ }
+}
diff --git a/blocks/vue/registry/default/realtime-avatar-stack/vue/composables/useCurrentUserName.ts b/blocks/vue/registry/default/realtime-avatar-stack/vue/composables/useCurrentUserName.ts
new file mode 100644
index 00000000000..98c29cac39f
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-avatar-stack/vue/composables/useCurrentUserName.ts
@@ -0,0 +1,26 @@
+import { ref, onMounted } from 'vue'
+// @ts-ignore
+import { createClient } from "@/lib/supabase/client"
+
+export function useCurrentUserName() {
+ const name = ref<string | null>(null)
+
+ const fetchProfileName = async () => {
+ const { data, error } = await createClient().auth.getSession()
+
+ if (error) {
+ console.error(error)
+ return
+ }
+
+ name.value = data.session?.user.user_metadata.full_name ?? '?'
+ }
+
+ onMounted(() => {
+ fetchProfileName()
+ })
+
+ return {
+ name,
+ }
+}
diff --git a/blocks/vue/registry/default/realtime-avatar-stack/vue/composables/useRealtimePresenceRoom.ts b/blocks/vue/registry/default/realtime-avatar-stack/vue/composables/useRealtimePresenceRoom.ts
new file mode 100644
index 00000000000..51e2578dfa9
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-avatar-stack/vue/composables/useRealtimePresenceRoom.ts
@@ -0,0 +1,95 @@
+import { ref, watch, onUnmounted } from 'vue'
+import { REALTIME_SUBSCRIBE_STATES } from '@supabase/supabase-js'
+
+import { useCurrentUserImage } from './useCurrentUserImage'
+import { useCurrentUserName } from './useCurrentUserName'
+// @ts-ignore
+import { createClient } from "@/lib/supabase/client"
+
+const supabase = createClient()
+
+export type RealtimeUser = {
+ id: string
+ name: string
+ image: string
+}
+
+export function useRealtimePresenceRoom(roomName: string) {
+ const { image: currentUserImage } = useCurrentUserImage()
+ const { name: currentUserName } = useCurrentUserName()
+
+ const users = ref<Record<string, RealtimeUser>>({})
+
+ let room: ReturnType<typeof supabase.channel> | null = null
+
+ function setupRoom() {
+ if (!roomName) return
+
+ room = supabase.channel(roomName)
+
+ room
+ .on('presence', { event: 'sync' }, () => {
+ const newState =
+ room?.presenceState<{ image: string; name: string }>() ?? {}
+
+ const newUsers = Object.fromEntries(
+ Object.entries(newState).map(([key, values]) => {
+ const typedValues = values as Array<{ image: string; name: string }>
+ if (typedValues.length > 0) {
+ return [
+ key,
+ {
+ id: key,
+ name: typedValues[0].name,
+ image: typedValues[0].image,
+ },
+ ]
+ } else {
+ return [
+ key,
+ {
+ id: key,
+ name: '',
+ image: '',
+ },
+ ]
+ }
+ })
+ ) as Record<string, RealtimeUser>
+
+ users.value = newUsers
+ })
+ .subscribe(async (status: REALTIME_SUBSCRIBE_STATES) => {
+ if (status === REALTIME_SUBSCRIBE_STATES.SUBSCRIBED && room) {
+ await room.track({
+ name: currentUserName.value,
+ image: currentUserImage.value,
+ })
+ } else {
+ users.value = {}
+ }
+ })
+ }
+
+ function cleanup() {
+ if (room) {
+ room.unsubscribe()
+ room = null
+ }
+ }
+
+ watch(
+ [() => roomName, currentUserName, currentUserImage],
+ () => {
+ cleanup()
+ setupRoom()
+ },
+ { immediate: true }
+ )
+
+ onUnmounted(() => {
+ cleanup()
+ })
+
+ return { users }
+}
diff --git a/blocks/vue/registry/default/realtime-avatar-stack/vue/registry-item.json b/blocks/vue/registry/default/realtime-avatar-stack/vue/registry-item.json
new file mode 100644
index 00000000000..089b5d74d0a
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-avatar-stack/vue/registry-item.json
@@ -0,0 +1,35 @@
+{
+ "name": "realtime-avatar-stack-vue",
+ "type": "registry:block",
+ "title": "Realtime Avatar Stack",
+ "description": "Component which stack of avatars, tracked by realtime presence.",
+ "registryDependencies": ["avatar", "tooltip"],
+ "files": [
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/components/realtime-avatar-stack.vue",
+ "type": "registry:component",
+ "target": "components/realtime-avatar-stack.vue"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/components/avatar-stack.vue",
+ "type": "registry:component",
+ "target": "components/avatar-stack.vue"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/composables/useCurrentUserImage.ts",
+ "type": "registry:component",
+ "target": "composables/useCurrentUserImage.ts"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/composables/useCurrentUserName.ts",
+ "type": "registry:component",
+ "target": "composables/useCurrentUserName.ts"
+ },
+ {
+ "path": "registry/default/realtime-avatar-stack/vue/composables/useRealtimePresenceRoom.ts",
+ "type": "registry:component",
+ "target": "composables/useRealtimePresenceRoom.ts"
+ }
+ ],
+ "dependencies": ["@supabase/supabase-js@latest"]
+}
\ No newline at end of file
diff --git a/blocks/vue/registry/index.ts b/blocks/vue/registry/index.ts
index 235404a5d7c..e18885012c7 100644
--- a/blocks/vue/registry/index.ts
+++ b/blocks/vue/registry/index.ts
@@ -3,7 +3,9 @@ import { dropzone } from './dropzone'
import { passwordBasedAuth } from './password-based-auth'
import { realtimeCursor } from './realtime-cursor'
import { socialAuth } from './social-auth'
+import { currentUserAvatar } from './current-user-avatar'
+import { realtimeAvatarStack } from './realtime-avatar-stack'
-const blocks = [...clients, ...passwordBasedAuth, ...socialAuth, ...dropzone, ...realtimeCursor]
+const blocks = [...clients, ...passwordBasedAuth, ...socialAuth, ...dropzone, ...realtimeCursor, ...currentUserAvatar, ...realtimeAvatarStack]
export { blocks }
diff --git a/blocks/vue/registry/realtime-avatar-stack.ts b/blocks/vue/registry/realtime-avatar-stack.ts
new file mode 100644
index 00000000000..25ca43c8f58
--- /dev/null
+++ b/blocks/vue/registry/realtime-avatar-stack.ts
@@ -0,0 +1,6 @@
+import { type RegistryItem } from 'shadcn/schema'
+
+import nuxtjs from './default/realtime-avatar-stack/nuxtjs/registry-item.json' with { type: 'json' }
+import vue from './default/realtime-avatar-stack/vue/registry-item.json' with { type: 'json' }
+
+export const realtimeAvatarStack = [nuxtjs, vue] as RegistryItem[]
\ No newline at end of file