Skip to content

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

docs: realtime chat/infinite query vue&nuxt (#44426)

Jakub Andrzejewskicadfc8731c4f
diff --git a/apps/ui-library/config/docs.ts b/apps/ui-library/config/docs.ts
index 24a3ac0c1d6..77203ce9a60 100644
--- a/apps/ui-library/config/docs.ts
+++ b/apps/ui-library/config/docs.ts
@@ -112,18 +112,18 @@ export const componentPages: SidebarNavGroup = {
},
{
title: 'Realtime Chat',
- supportedFrameworks: ['nextjs', 'react-router', 'tanstack', 'react'],
+ supportedFrameworks: ['nextjs', 'react-router', 'tanstack', 'react', 'vue', 'nuxtjs'],
href: '/docs/nextjs/realtime-chat',
items: [],
commandItemLabel: 'Realtime Chat',
},
{
- title: 'Infinite Query Hook',
- supportedFrameworks: [],
- href: '/docs/infinite-query-hook',
+ title: 'Infinite Query',
+ supportedFrameworks: ['react', 'vue'],
+ href: '/docs/react/infinite-query',
new: true,
items: [],
- commandItemLabel: 'Infinite Query Hook',
+ commandItemLabel: 'Infinite Query',
},
],
}
diff --git a/apps/ui-library/content/docs/nuxtjs/realtime-chat.mdx b/apps/ui-library/content/docs/nuxtjs/realtime-chat.mdx
new file mode 100644
index 00000000000..e1435d6941f
--- /dev/null
+++ b/apps/ui-library/content/docs/nuxtjs/realtime-chat.mdx
@@ -0,0 +1,128 @@
+---
+title: Realtime Chat
+description: Real-time chat component for collaborative applications
+---
+
+<DualRealtimeChat />
+
+## Installation
+
+<BlockItem
+ name="realtime-chat-nuxtjs"
+ description="Renders a real-time chat interface for users in a shared room."
+/>
+
+## Folder structure
+
+This block assumes that you have already installed a Supabase client for Vue from the previous step.
+
+<RegistryBlock itemName="realtime-chat-nuxtjs" />
+
+## Introduction
+
+The Realtime Chat component provides a complete chat interface that enables users to exchange messages in real-time within a shared room.
+
+## How it works under the hood
+
+This chat component uses **Supabase Realtime Broadcast** to send and receive messages between connected clients.
+
+Messages sent through Broadcast are:
+
+- delivered in real time to other connected clients
+- **not stored** unless you handle persistence yourself
+- **not guaranteed** to arrive if the client disconnects
+- scoped to a specific `roomName`, which corresponds to a broadcast channel
+
+This design keeps latency extremely low, but it means you should use the `onMessage` callback if you want to store messages permanently or show chat history on page load.
+
+## Usage
+
+### Basic usage
+
+```html
+<script setup lang="ts">
+ import RealtimeChat from '@/components/realtime-chat.vue'
+</script>
+
+<template>
+ <RealtimeChat roomName="my-chat-room" username="john_doe" />
+</template>
+```
+
+### With initial messages
+
+```html
+<script setup lang="ts">
+ import RealtimeChat from '@/components/realtime-chat.vue'
+ import { useMessagesQuery } from '@/composables/use-messages-query'
+
+ const { data } = useMessagesQuery()
+</script>
+
+<template>
+ <RealtimeChat roomName="my-chat-room" username="john_doe" :messages="data ?? []" />
+</template>
+```
+
+### Storing messages
+
+```html
+<script setup lang="ts">
+ import RealtimeChat from '@/components/realtime-chat.vue'
+ import { useMessagesQuery } from '@/composables/use-messages-query'
+ import { storeMessages } from '@/lib/store-messages'
+ import type { ChatMessage } from '@/types'
+
+ const { data } = useMessagesQuery()
+
+ // Callback function for new messages
+ const handleMessage = async (messages: ChatMessage[]) => {
+ await storeMessages(messages)
+ }
+</script>
+
+<template>
+ <RealtimeChat
+ roomName="my-chat-room"
+ username="john_doe"
+ :messages="data ?? []"
+ :onMessage="handleMessage"
+ />
+</template>
+```
+
+## Features
+
+- Real-time message synchronization
+- Message persistence support with `onMessage` and `messages` props
+- Customizable message appearance
+- Automatic scroll-to-bottom on new messages
+- Room-based isolation for scoped conversations
+- Low-latency updates using Supabase Realtime
+
+## Props
+
+| Prop | Type | Description |
+| ------------ | ----------------------------------- | ------------------------------------------------------------- |
+| `roomName` | `string` | Unique identifier for the shared chat room. |
+| `username` | `string` | Name of the current user; used to identify message senders. |
+| `onMessage?` | `(messages: ChatMessage[]) => void` | Optional callback to handle messages, useful for persistence. |
+| `messages?` | `ChatMessage[]` | Optional initial messages to display in the chat. |
+
+### ChatMessage type
+
+```typescript
+interface ChatMessage {
+ id: string
+ content: string
+ user: {
+ name: string
+ }
+ createdAt: string
+}
+```
+
+## Further reading
+
+- [Realtime Broadcast](https://supabase.com/docs/guides/realtime/broadcast)
+- [Realtime authorization](https://supabase.com/docs/guides/realtime/authorization)
diff --git a/apps/ui-library/content/docs/infinite-query-hook.mdx b/apps/ui-library/content/docs/react/infinite-query.mdx
similarity index 100%
rename from apps/ui-library/content/docs/infinite-query-hook.mdx
rename to apps/ui-library/content/docs/react/infinite-query.mdx
diff --git a/apps/ui-library/content/docs/vue/infinite-query.mdx b/apps/ui-library/content/docs/vue/infinite-query.mdx
new file mode 100644
index 00000000000..fd713011c63
--- /dev/null
+++ b/apps/ui-library/content/docs/vue/infinite-query.mdx
@@ -0,0 +1,281 @@
+---
+title: Infinite Query Composable
+description: Vue Composable for infinite lists, fetching data from Supabase.
+---
+
+<BlockPreview name="infinite-list-demo" />
+
+## Installation
+
+<BlockItem
+ name="infinite-query-composable"
+ description="Installs the Infinite List component and necessary Supabase client setup."
+/>
+
+## Folder structure
+
+<RegistryBlock itemName="infinite-query-composable" />
+
+## Introduction
+
+The Infinite Query Composable provides a single Vue Composable which will make it easier to load data progressively from your Supabase database. It handles data fetching and pagination state, It is meant to be used with infinite lists or tables.
+The Composable is fully typed, provided you have generated and setup your database types.
+
+## Adding types
+
+Before using this composable, we **highly** recommend you setup database types in your project. This will make the composable fully-typesafe. More info about generating Typescript types from database schema [here](https://supabase.com/docs/guides/api/rest/generating-types)
+
+## Props
+
+| Prop | Type | Description |
+| --------------- | --------------------------------------------------------- | ---------------------------------------------------------------- |
+| `tableName` | `string` | **Required.** The name of the Supabase table to fetch data from. |
+| `columns` | `string` | Columns to select from the table. Defaults to `'*'`. |
+| `pageSize` | `number` | Number of items to fetch per page. Defaults to `20`. |
+| `trailingQuery` | `(query: SupabaseSelectBuilder) => SupabaseSelectBuilder` | Function to apply filters or sorting to the Supabase query. |
+
+## Return type
+
+data, count, isSuccess, isLoading, isFetching, error, hasMore, fetchNextPage
+
+| Prop | Type | Description |
+| --------------- | ------------- | ----------------------------------------------------------------------------------- |
+| `data` | `TableData[]` | An array of fetched items. |
+| `count` | `number` | Number of total items in the database. It takes `trailingQuery` into consideration. |
+| `isSuccess` | `boolean` | It's true if the last API call succeeded. |
+| `isLoading` | `boolean` | It's true only for the initial fetch. |
+| `isFetching` | `boolean` | It's true for the initial and all incremental fetches. |
+| `error` | `any` | The error from the last fetch. |
+| `hasMore` | `boolean` | Whether the query has finished fetching all items from the database |
+| `fetchNextPage` | `() => void` | Sends a new request for the next items |
+
+## Type safety
+
+The hook will use the typed defined on your Supabase client if they're setup ([more info](https://supabase.com/docs/reference/javascript/typescript-support)).
+
+The hook also supports an custom defined result type by using `useInfiniteQuery<T>`. For example, if you have a custom type for `Product`, you can use it like this `useInfiniteQuery<Product>`.
+
+## Usage
+
+### With sorting
+
+```vue
+<script setup lang="ts">
+import { useInfiniteQuery } from '@/composables/useInfiniteQuery.ts'
+
+const { data, fetchNextPage } = useInfiniteQuery({
+ tableName: 'products',
+ columns: '*',
+ pageSize: 10,
+ trailingQuery: (query) => query.order('created_at', { ascending: false }),
+})
+</script>
+
+<template>
+ <div>
+ <div v-for="item in data" :key="item.id">
+ <ProductCard :product="item" />
+ </div>
+ <Button @click="fetchNextPage">Load more products</Button>
+ </div>
+</template>
+```
+
+### With filtering on search params
+
+This example will filter based on a search param like `example.com/?q=hello`.
+
+```vue
+<script setup lang="ts">
+import { computed } from 'vue'
+import { useRoute } from 'vue-router'
+
+import { useInfiniteQuery } from '@/hooks/use-infinite-query'
+
+const route = useRoute()
+const searchQuery = computed(() => route.query.q as string | undefined)
+
+const { data, isLoading, isFetching, fetchNextPage, count, isSuccess } = useInfiniteQuery({
+ tableName: 'products',
+ columns: '*',
+ pageSize: 10,
+ trailingQuery: (query) => {
+ if (searchQuery.value && searchQuery.value.length > 0) {
+ query = query.ilike('name', `%${searchQuery.value}%`)
+ }
+ return query
+ },
+})
+</script>
+
+<template>
+ <div>
+ <div v-for="item in data" :key="item.id">
+ <ProductCard :product="item" />
+ </div>
+ <Button @click="fetchNextPage">Load more products</Button>
+ </div>
+</template>
+```
+
+## Reusable components
+
+### Infinite list (fetches as you scroll)
+
+The following component abstracts the composable into a component. It includes few utility components for no results and end of the list.
+
+```vue
+<script setup lang="ts">
+import { onBeforeUnmount, onMounted, ref } from 'vue'
+
+import {
+ SupabaseQueryHandler,
+ SupabaseTableData,
+ SupabaseTableName,
+ useInfiniteQuery,
+} from '@/hooks/use-infinite-query'
+import { cn } from '@/lib/utils'
+
+interface InfiniteListProps<TableName extends SupabaseTableName> {
+ tableName: TableName
+ columns?: string
+ pageSize?: number
+ trailingQuery?: SupabaseQueryHandler<TableName>
+ renderItem: (item: SupabaseTableData<TableName>, index: number) => any
+ className?: string
+ renderNoResults?: () => any
+ renderEndMessage?: () => any
+ renderSkeleton?: (count: number) => any
+}
+
+const props = defineProps<InfiniteListProps<any>>()
+
+const { data, isFetching, hasMore, fetchNextPage, isSuccess } = useInfiniteQuery({
+ tableName: props.tableName,
+ columns: props.columns,
+ pageSize: props.pageSize,
+ trailingQuery: props.trailingQuery,
+})
+
+const scrollContainerRef = ref<HTMLElement | null>(null)
+const loadMoreSentinelRef = ref<HTMLElement | null>(null)
+
+let observer: IntersectionObserver | null = null
+
+onMounted(() => {
+ observer = new IntersectionObserver(
+ (entries) => {
+ if (entries[0].isIntersecting && hasMore && !isFetching) {
+ fetchNextPage()
+ }
+ },
+ {
+ root: scrollContainerRef.value,
+ threshold: 0.1,
+ rootMargin: '0px 0px 100px 0px',
+ }
+ )
+
+ if (loadMoreSentinelRef.value) {
+ observer.observe(loadMoreSentinelRef.value)
+ }
+})
+
+onBeforeUnmount(() => {
+ observer?.disconnect()
+})
+</script>
+
+<template>
+ <div ref="scrollContainerRef" :class="cn('relative h-full overflow-auto', className)">
+ <div>
+ <template v-if="isSuccess && data.length === 0">
+ <slot name="no-results">
+ <div class="text-center text-muted-foreground py-10">No results.</div>
+ </slot>
+ </template>
+
+ <template v-for="(item, index) in data" :key="index">
+ <slot :item="item" :index="index" />
+ </template>
+
+ <template v-if="isFetching">
+ <slot name="skeleton" :count="pageSize" />
+ </template>
+
+ <div ref="loadMoreSentinelRef" style="height: 1px" />
+
+ <template v-if="!hasMore && data.length > 0">
+ <slot name="end">
+ <div class="text-center text-muted-foreground py-4 text-sm">You've reached the end.</div>
+ </slot>
+ </template>
+ </div>
+ </div>
+</template>
+```
+
+Use the `InfiniteList` component with the [Todo List](https://supabase.com/dashboard/project/_/sql/quickstarts) quickstart.
+
+Add `<InfiniteListDemo />` to a page to see it in action.
+Ensure the [Checkbox](https://ui.shadcn.com/docs/components/checkbox) component from shadcn/ui is installed, and [regenerate/download](https://supabase.com/docs/guides/api/rest/generating-types) types after running the quickstart.
+
+```vue
+<script setup lang="ts">
+import { InfiniteList } from './infinite-component'
+import { Checkbox } from '@/components/ui/checkbox'
+import { SupabaseQueryHandler } from '@/hooks/use-infinite-query'
+import { Database } from '@/lib/supabase.types'
+
+type TodoTask = Database['public']['Tables']['todos']['Row']
+
+const renderTodoItem = (todo: TodoTask) => {
+ return (
+ <div
+ key={todo.id}
+ className="border-b py-3 px-4 hover:bg-muted flex items-center justify-between"
+ >
+ <div className="flex items-center gap-3">
+ <Checkbox modelValue={todo.is_complete ?? false} />
+ <div>
+ <span className="font-medium text-sm text-foreground">{todo.task}</span>
+ <div className="text-sm text-muted-foreground">
+ {new Date(todo.inserted_at).toLocaleDateString()}
+ </div>
+ </div>
+ </div>
+ </div>
+ )
+}
+
+const orderByInsertedAt: SupabaseQueryHandler<'todos'> = (query) => {
+ return query.order('inserted_at', { ascending: false })
+}
+</script>
+
+<template>
+ <div class="bg-background h-[600px]">
+ <InfiniteList
+ tableName="todos"
+ :renderItem="renderTodoItem"
+ :pageSize="3"
+ :trailingQuery="orderByInsertedAt"
+ />
+ </div>
+</template>
+```
+
+<Callout>
+ The Todo List table has Row Level Security (RLS) enabled by default. Feel free disable it
+ temporarily while testing. With RLS enabled, you will get an [empty
+ array](https://supabase.com/docs/guides/troubleshooting/why-is-my-select-returning-an-empty-data-array-and-i-have-data-in-the-table-xvOPgx)
+ of results by default. [Read
+ more](https://supabase.com/docs/guides/database/postgres/row-level-security) about RLS.
+</Callout>
+
+## Further reading
+
+- [Generating Typescript types from the database](https://supabase.com/docs/reference/javascript/typescript-support)
+- [Supabase Database API](https://supabase.com/docs/reference/javascript/select)
+- [Supabase Pagination](https://supabase.com/docs/reference/javascript/select#pagination)
+- [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
diff --git a/apps/ui-library/content/docs/vue/realtime-chat.mdx b/apps/ui-library/content/docs/vue/realtime-chat.mdx
new file mode 100644
index 00000000000..2fc60e7f0c9
--- /dev/null
+++ b/apps/ui-library/content/docs/vue/realtime-chat.mdx
@@ -0,0 +1,115 @@
+---
+title: Realtime Chat
+description: Real-time chat component for collaborative applications
+---
+
+<DualRealtimeChat />
+
+## Installation
+
+<BlockItem
+ name="realtime-chat-vue"
+ description="Renders a real-time chat interface for users in a shared room."
+/>
+
+## Folder structure
+
+This block assumes that you have already installed a Supabase client for Vue from the previous step.
+
+<RegistryBlock itemName="realtime-chat-vue" />
+
+## Introduction
+
+The Realtime Chat component provides a complete chat interface that enables users to exchange messages in real-time within a shared room.
+
+## Usage
+
+### Basic usage
+
+```html
+<script setup lang="ts">
+ import RealtimeChat from '@/components/realtime-chat.vue'
+</script>
+
+<template>
+ <RealtimeChat roomName="my-chat-room" username="john_doe" />
+</template>
+```
+
+### With initial messages
+
+```html
+<script setup lang="ts">
+ import RealtimeChat from '@/components/realtime-chat.vue'
+ import { useMessagesQuery } from '@/composables/use-messages-query'
+
+ const { data } = useMessagesQuery()
+</script>
+
+<template>
+ <RealtimeChat roomName="my-chat-room" username="john_doe" :messages="data ?? []" />
+</template>
+```
+
+### Storing messages
+
+```html
+<script setup lang="ts">
+ import RealtimeChat from '@/components/realtime-chat.vue'
+ import { useMessagesQuery } from '@/composables/use-messages-query'
+ import { storeMessages } from '@/lib/store-messages'
+ import type { ChatMessage } from '@/types'
+
+ const { data } = useMessagesQuery()
+
+ // Callback function for new messages
+ const handleMessage = async (messages: ChatMessage[]) => {
+ await storeMessages(messages)
+ }
+</script>
+
+<template>
+ <RealtimeChat
+ roomName="my-chat-room"
+ username="john_doe"
+ :messages="data ?? []"
+ :onMessage="handleMessage"
+ />
+</template>
+```
+
+## Features
+
+- Real-time message synchronization
+- Message persistence support with `onMessage` and `messages` props
+- Customizable message appearance
+- Automatic scroll-to-bottom on new messages
+- Room-based isolation for scoped conversations
+- Low-latency updates using Supabase Realtime
+
+## Props
+
+| Prop | Type | Description |
+| ------------ | ----------------------------------- | ------------------------------------------------------------- |
+| `roomName` | `string` | Unique identifier for the shared chat room. |
+| `username` | `string` | Name of the current user; used to identify message senders. |
+| `onMessage?` | `(messages: ChatMessage[]) => void` | Optional callback to handle messages, useful for persistence. |
+| `messages?` | `ChatMessage[]` | Optional initial messages to display in the chat. |
+
+### ChatMessage type
+
+```typescript
+interface ChatMessage {
+ id: string
+ content: string
+ user: {
+ name: string
+ }
+ createdAt: string
+}
+```
+
+## Further reading
+
+- [Realtime Broadcast](https://supabase.com/docs/guides/realtime/broadcast)
+- [Realtime authorization](https://supabase.com/docs/guides/realtime/authorization)
diff --git a/apps/ui-library/public/r/infinite-query-composable.json b/apps/ui-library/public/r/infinite-query-composable.json
new file mode 100644
index 00000000000..c1003d9239c
--- /dev/null
+++ b/apps/ui-library/public/r/infinite-query-composable.json
@@ -0,0 +1,19 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "infinite-query-composable",
+ "type": "registry:component",
+ "title": "Infinite Query for Vue and Supabase",
+ "description": "Vue Composable for infinite lists, fetching data from Supabase.",
+ "dependencies": [
+ "@supabase/supabase-js@latest",
+ "@supabase/postgrest-js@*"
+ ],
+ "files": [
+ {
+ "path": "registry/default/infinite-query/vue/composables/useInfiniteQuery.ts",
+ "content": "import { PostgrestQueryBuilder, type PostgrestClientOptions } from '@supabase/postgrest-js'\nimport { type SupabaseClient } from '@supabase/supabase-js'\nimport { computed, onMounted, reactive, toRefs, watch } from 'vue'\n\n// @ts-ignore\nimport { createClient } from '@/lib/supabase/client'\n\nconst supabase = createClient()\n\ntype SupabaseClientType = typeof supabase\n\ntype IfAny<T, Y, N> = 0 extends 1 & T ? Y : N\n\ntype Database =\n SupabaseClientType extends SupabaseClient<infer U>\n ? IfAny<\n U,\n {\n public: {\n Tables: Record<string, any>\n Views: Record<string, any>\n Functions: Record<string, any>\n }\n },\n U\n >\n : {\n public: {\n Tables: Record<string, any>\n Views: Record<string, any>\n Functions: Record<string, any>\n }\n }\n\ntype DatabaseSchema = Database['public']\ntype SupabaseTableName = keyof DatabaseSchema['Tables']\ntype SupabaseTableData<T extends SupabaseTableName> = DatabaseSchema['Tables'][T]['Row']\n\ntype DefaultClientOptions = PostgrestClientOptions\n\ntype SupabaseSelectBuilder<T extends SupabaseTableName> = ReturnType<\n PostgrestQueryBuilder<\n DefaultClientOptions,\n DatabaseSchema,\n DatabaseSchema['Tables'][T],\n T\n >['select']\n>\n\nexport type SupabaseQueryHandler<T extends SupabaseTableName> = (\n query: SupabaseSelectBuilder<T>\n) => SupabaseSelectBuilder<T>\n\nexport interface UseInfiniteQueryProps<T extends SupabaseTableName> {\n tableName: T\n columns?: string\n pageSize?: number\n trailingQuery?: SupabaseQueryHandler<T>\n}\n\ninterface State<TData> {\n data: TData[]\n count: number\n isSuccess: boolean\n isLoading: boolean\n isFetching: boolean\n error: Error | null\n hasInitialFetch: boolean\n requestCounter: number\n}\n\n// --------------------\n// Composable\n// --------------------\n\nexport function useInfiniteQuery<\n TData extends SupabaseTableData<T>,\n T extends SupabaseTableName = SupabaseTableName,\n>(props: UseInfiniteQueryProps<T>) {\n const state = reactive<State<TData>>({\n data: [],\n count: 0,\n isSuccess: false,\n isLoading: false,\n isFetching: false,\n error: null,\n hasInitialFetch: false,\n requestCounter: 0,\n })\n\n const pageSize = computed(() => props.pageSize ?? 20)\n const columns = computed(() => props.columns ?? '*')\n\n const fetchPage = async (skip: number) => {\n // Capture the current request token to validate this request later\n const requestToken = state.requestCounter\n\n if (state.hasInitialFetch && (state.isFetching || state.data.length >= state.count)) {\n return\n }\n\n // Early return if request has been invalidated\n if (requestToken !== state.requestCounter) {\n return\n }\n\n state.isFetching = true\n\n let query = supabase\n .from(props.tableName)\n .select(columns.value, { count: 'exact' }) as unknown as SupabaseSelectBuilder<T>\n\n if (props.trailingQuery) {\n query = props.trailingQuery(query)\n }\n\n const { data, count, error } = await query.range(skip, skip + pageSize.value - 1)\n\n // Verify that this request is still valid before mutating state\n if (requestToken !== state.requestCounter) {\n state.isFetching = false\n return\n }\n\n if (error) {\n console.error(error)\n state.error = error\n } else {\n state.data.push(...(data as TData[]))\n state.count = count || 0\n state.isSuccess = true\n state.error = null\n }\n\n state.isFetching = false\n }\n\n const fetchNextPage = async () => {\n if (state.isFetching) return\n await fetchPage(state.data.length)\n }\n\n const reset = () => {\n state.data = []\n state.count = 0\n state.isSuccess = false\n state.error = null\n state.hasInitialFetch = false\n state.isFetching = false\n state.requestCounter++\n }\n\n const initialize = async () => {\n state.isLoading = true\n reset()\n\n await fetchNextPage()\n\n state.isLoading = false\n state.hasInitialFetch = true\n }\n\n // React-style deps → Vue watch\n watch(\n () => [props.tableName, props.columns, props.pageSize],\n () => {\n if (state.hasInitialFetch) {\n initialize()\n }\n }\n )\n\n onMounted(() => {\n if (!state.hasInitialFetch) {\n initialize()\n }\n })\n\n const hasMore = computed(() => state.count > state.data.length)\n\n return {\n ...toRefs(state),\n hasMore,\n fetchNextPage,\n refresh: initialize,\n }\n}\n",
+ "type": "registry:component",
+ "target": "composables/useInfiniteQuery.ts"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/apps/ui-library/public/r/realtime-chat-nuxtjs.json b/apps/ui-library/public/r/realtime-chat-nuxtjs.json
new file mode 100644
index 00000000000..8c84e2c8425
--- /dev/null
+++ b/apps/ui-library/public/r/realtime-chat-nuxtjs.json
@@ -0,0 +1,41 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "realtime-chat-nuxtjs",
+ "type": "registry:block",
+ "title": "Realtime Chat",
+ "description": "Component which provides a realtime chat interface.",
+ "dependencies": [
+ "@supabase/supabase-js@latest",
+ "lucide-vue-next@latest"
+ ],
+ "registryDependencies": [
+ "button",
+ "input"
+ ],
+ "files": [
+ {
+ "path": "registry/default/realtime-chat/nuxtjs/app/components/realtime-chat.vue",
+ "content": "<script setup lang=\"ts\">\nimport { ref, computed, watch } from 'vue'\nimport { Send } from 'lucide-vue-next'\n\nimport ChatMessageItem from './chat-message-item.vue'\nimport { useChatScroll } from '../composables/useChatScroll'\nimport {\n useRealtimeChat,\n type ChatMessage,\n} from '../composables/useRealtimeChat'\n // @ts-ignore\nimport Button from '@/components/ui/Button.vue'\n // @ts-ignore\nimport Input from '@/components/ui/Input.vue'\n\ninterface RealtimeChatProps {\n roomName: string\n username: string\n onMessage?: (messages: ChatMessage[]) => void\n messages?: ChatMessage[]\n}\n\nconst props = defineProps<RealtimeChatProps>()\n\nconst initialMessages = computed(() => props.messages ?? [])\n\nconst { containerRef, scrollToBottom } = useChatScroll()\n\nconst { messages: realtimeMessages, sendMessage, isConnected } =\n useRealtimeChat({\n roomName: props.roomName,\n username: props.username,\n })\n\nconst newMessage = ref('')\n\n/**\n * Merge + dedupe + sort\n */\nconst allMessages = computed<ChatMessage[]>(() => {\n const merged = [...initialMessages.value, ...realtimeMessages.value]\n\n const unique = merged.filter(\n (message, index, self) =>\n index === self.findIndex((m) => m.id === message.id)\n )\n\n return unique.sort((a, b) =>\n a.createdAt.localeCompare(b.createdAt)\n )\n})\n\n/**\n * Emit messages to parent if callback provided\n */\nwatch(allMessages, (messages) => {\n if (props.onMessage) {\n props.onMessage(messages)\n }\n\n scrollToBottom()\n}, { flush: 'post' })\n\nfunction handleSendMessage() {\n if (!newMessage.value.trim() || !isConnected.value) return\n\n sendMessage(newMessage.value)\n newMessage.value = ''\n}\n</script>\n\n<template>\n <div class=\"flex flex-col h-full w-full bg-background text-foreground antialiased\">\n <!-- Messages -->\n <div\n ref=\"containerRef\"\n class=\"flex-1 overflow-y-auto p-4 space-y-4\"\n >\n <div\n v-if=\"allMessages.length === 0\"\n class=\"text-center text-sm text-muted-foreground\"\n >\n No messages yet. Start the conversation!\n </div>\n\n <div class=\"space-y-1\">\n <div\n v-for=\"(message, index) in allMessages\"\n :key=\"message.id\"\n class=\"animate-in fade-in slide-in-from-bottom-4 duration-300\"\n >\n <ChatMessageItem\n :message=\"message\"\n :isOwnMessage=\"message.user.name === props.username\"\n :showHeader=\"\n !allMessages[index - 1] ||\n allMessages[index - 1].user.name !== message.user.name\n \"\n />\n </div>\n </div>\n </div>\n\n <!-- Input -->\n <form\n @submit.prevent=\"handleSendMessage\"\n class=\"flex w-full gap-2 border-t border-border p-4\"\n >\n <Input\n v-model=\"newMessage\"\n :disabled=\"!isConnected\"\n type=\"text\"\n placeholder=\"Type a message...\"\n :class=\"[\n 'rounded-full bg-background text-sm transition-all duration-300',\n isConnected && newMessage.trim()\n ? 'w-[calc(100%-36px)]'\n : 'w-full',\n ]\"\n />\n\n <Button\n v-if=\"isConnected && newMessage.trim()\"\n type=\"submit\"\n :disabled=\"!isConnected\"\n class=\"aspect-square rounded-full animate-in fade-in slide-in-from-right-4 duration-300\"\n >\n <Send class=\"size-4\" />\n </Button>\n </form>\n </div>\n</template>\n",
+ "type": "registry:component",
+ "target": "app/components/realtime-chat.vue"
+ },
+ {
+ "path": "registry/default/realtime-chat/nuxtjs/app/components/chat-message-item.vue",
+ "content": "<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport type { ChatMessage } from '../composables/useRealtimeChat'\n\nconst props = defineProps<{\n message: ChatMessage\n isOwnMessage: boolean\n showHeader: boolean\n}>()\n\nconst containerClasses = computed(() => [\n 'flex mt-2',\n props.isOwnMessage ? 'justify-end' : 'justify-start',\n])\n\nconst wrapperClasses = computed(() => [\n 'max-w-[75%] w-fit flex flex-col gap-1',\n props.isOwnMessage ? 'items-end' : '',\n])\n\nconst headerClasses = computed(() => [\n 'flex items-center gap-2 text-xs px-3',\n props.isOwnMessage ? 'justify-end flex-row-reverse' : '',\n])\n\nconst bubbleClasses = computed(() => [\n 'py-2 px-3 rounded-xl text-sm w-fit',\n props.isOwnMessage\n ? 'bg-primary text-primary-foreground'\n : 'bg-muted text-foreground',\n])\n\nconst formattedTime = computed(() =>\n new Date(props.message.createdAt).toLocaleTimeString('en-US', {\n hour: '2-digit',\n minute: '2-digit',\n hour12: true,\n })\n)\n</script>\n\n<template>\n <div :class=\"containerClasses\">\n <div :class=\"wrapperClasses\">\n <!-- Header -->\n <div v-if=\"showHeader\" :class=\"headerClasses\">\n <span class=\"font-medium\">\n {{ message.user.name }}\n </span>\n\n <span class=\"text-foreground/50 text-xs\">\n {{ formattedTime }}\n </span>\n </div>\n\n <!-- Message Bubble -->\n <div :class=\"bubbleClasses\">\n {{ message.content }}\n </div>\n </div>\n </div>\n</template>\n",
+ "type": "registry:component",
+ "target": "app/components/chat-message-item.vue"
+ },
+ {
+ "path": "registry/default/realtime-chat/nuxtjs/app/composables/useChatScroll.ts",
+ "content": "import { ref } from 'vue'\n\nexport function useChatScroll() {\n const containerRef = ref<HTMLDivElement | null>(null)\n\n function scrollToBottom() {\n if (!containerRef.value) return\n\n const container = containerRef.value\n\n container.scrollTo({\n top: container.scrollHeight,\n behavior: 'smooth',\n })\n }\n\n return {\n containerRef,\n scrollToBottom,\n }\n}\n",
+ "type": "registry:component",
+ "target": "app/composables/useChatScroll.ts"
+ },
+ {
+ "path": "registry/default/realtime-chat/nuxtjs/app/composables/useRealtimeChat.ts",
+ "content": "import { onUnmounted, ref, watch } from 'vue'\n\n// @ts-ignore\nimport { createClient } from '@/lib/supabase/client'\n\ninterface UseRealtimeChatProps {\n roomName: string\n username: string\n}\n\nexport interface ChatMessage {\n id: string\n content: string\n user: {\n name: string\n }\n createdAt: string\n}\n\nconst EVENT_MESSAGE_TYPE = 'message'\n\nexport function useRealtimeChat(props: UseRealtimeChatProps) {\n const supabase = createClient()\n\n const messages = ref<ChatMessage[]>([])\n const channel = ref<ReturnType<typeof supabase.channel> | null>(null)\n const isConnected = ref(false)\n\n function cleanup() {\n if (channel.value) {\n supabase.removeChannel(channel.value)\n channel.value = null\n }\n }\n\n function setupChannel() {\n if (!props.roomName) return\n\n const newChannel = supabase.channel(props.roomName)\n\n newChannel\n .on('broadcast', { event: EVENT_MESSAGE_TYPE }, (payload: { payload: ChatMessage }) => {\n messages.value.push(payload.payload as ChatMessage)\n })\n .subscribe((status: string) => {\n isConnected.value = status === 'SUBSCRIBED'\n })\n\n channel.value = newChannel\n }\n\n watch(\n () => props.roomName,\n () => {\n cleanup()\n setupChannel()\n },\n { immediate: true }\n )\n\n onUnmounted(() => {\n cleanup()\n })\n\n async function sendMessage(content: string) {\n if (!channel.value || !isConnected.value) return\n\n const message: ChatMessage = {\n id: crypto.randomUUID(),\n content,\n user: {\n name: props.username,\n },\n createdAt: new Date().toISOString(),\n }\n\n // Optimistic update\n messages.value.push(message)\n\n await channel.value.send({\n type: 'broadcast',\n event: EVENT_MESSAGE_TYPE,\n payload: message,\n })\n }\n\n return {\n messages,\n sendMessage,\n isConnected,\n }\n}\n",
+ "type": "registry:component",
+ "target": "app/composables/useRealtimeChat.ts"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/apps/ui-library/public/r/realtime-chat-vue.json b/apps/ui-library/public/r/realtime-chat-vue.json
new file mode 100644
index 00000000000..09b3b18e66d
--- /dev/null
+++ b/apps/ui-library/public/r/realtime-chat-vue.json
@@ -0,0 +1,41 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "realtime-chat-vue",
+ "type": "registry:block",
+ "title": "Realtime Chat",
+ "description": "Component which provides a realtime chat interface.",
+ "dependencies": [
+ "@supabase/supabase-js@latest",
+ "lucide-vue-next@latest"
+ ],
+ "registryDependencies": [
+ "button",
+ "input"
+ ],
+ "files": [
+ {
+ "path": "registry/default/realtime-chat/vue/components/realtime-chat.vue",
+ "content": "<script setup lang=\"ts\">\nimport { ref, computed, watch } from 'vue'\nimport { Send } from 'lucide-vue-next'\n\nimport ChatMessageItem from './chat-message-item.vue'\nimport { useChatScroll } from '../composables/useChatScroll'\nimport {\n useRealtimeChat,\n type ChatMessage,\n} from '../composables/useRealtimeChat'\n // @ts-ignore\nimport Button from '@/components/ui/Button.vue'\n // @ts-ignore\nimport Input from '@/components/ui/Input.vue'\n\ninterface RealtimeChatProps {\n roomName: string\n username: string\n onMessage?: (messages: ChatMessage[]) => void\n messages?: ChatMessage[]\n}\n\nconst props = defineProps<RealtimeChatProps>()\n\nconst initialMessages = computed(() => props.messages ?? [])\n\nconst { containerRef, scrollToBottom } = useChatScroll()\n\nconst { messages: realtimeMessages, sendMessage, isConnected } =\n useRealtimeChat({\n roomName: props.roomName,\n username: props.username,\n })\n\nconst newMessage = ref('')\n\n/**\n * Merge + dedupe + sort\n */\nconst allMessages = computed<ChatMessage[]>(() => {\n const merged = [...initialMessages.value, ...realtimeMessages.value]\n\n const unique = merged.filter(\n (message, index, self) =>\n index === self.findIndex((m) => m.id === message.id)\n )\n\n return unique.sort((a, b) =>\n a.createdAt.localeCompare(b.createdAt)\n )\n})\n\n/**\n * Emit messages to parent if callback provided\n */\nwatch(allMessages, (messages) => {\n if (props.onMessage) {\n props.onMessage(messages)\n }\n\n scrollToBottom()\n}, { flush: 'post' })\n\nfunction handleSendMessage() {\n if (!newMessage.value.trim() || !isConnected.value) return\n\n sendMessage(newMessage.value)\n newMessage.value = ''\n}\n</script>\n\n<template>\n <div class=\"flex flex-col h-full w-full bg-background text-foreground antialiased\">\n <!-- Messages -->\n <div\n ref=\"containerRef\"\n class=\"flex-1 overflow-y-auto p-4 space-y-4\"\n >\n <div\n v-if=\"allMessages.length === 0\"\n class=\"text-center text-sm text-muted-foreground\"\n >\n No messages yet. Start the conversation!\n </div>\n\n <div class=\"space-y-1\">\n <div\n v-for=\"(message, index) in allMessages\"\n :key=\"message.id\"\n class=\"animate-in fade-in slide-in-from-bottom-4 duration-300\"\n >\n <ChatMessageItem\n :message=\"message\"\n :isOwnMessage=\"message.user.name === props.username\"\n :showHeader=\"\n !allMessages[index - 1] ||\n allMessages[index - 1].user.name !== message.user.name\n \"\n />\n </div>\n </div>\n </div>\n\n <!-- Input -->\n <form\n @submit.prevent=\"handleSendMessage\"\n class=\"flex w-full gap-2 border-t border-border p-4\"\n >\n <Input\n v-model=\"newMessage\"\n :disabled=\"!isConnected\"\n type=\"text\"\n placeholder=\"Type a message...\"\n :class=\"[\n 'rounded-full bg-background text-sm transition-all duration-300',\n isConnected && newMessage.trim()\n ? 'w-[calc(100%-36px)]'\n : 'w-full',\n ]\"\n />\n\n <Button\n v-if=\"isConnected && newMessage.trim()\"\n type=\"submit\"\n :disabled=\"!isConnected\"\n class=\"aspect-square rounded-full animate-in fade-in slide-in-from-right-4 duration-300\"\n >\n <Send class=\"size-4\" />\n </Button>\n </form>\n </div>\n</template>\n",
+ "type": "registry:component",
+ "target": "components/realtime-chat.vue"
+ },
+ {
+ "path": "registry/default/realtime-chat/vue/components/chat-message-item.vue",
+ "content": "<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport type { ChatMessage } from '../composables/useRealtimeChat'\n\nconst props = defineProps<{\n message: ChatMessage\n isOwnMessage: boolean\n showHeader: boolean\n}>()\n\nconst containerClasses = computed(() => [\n 'flex mt-2',\n props.isOwnMessage ? 'justify-end' : 'justify-start',\n])\n\nconst wrapperClasses = computed(() => [\n 'max-w-[75%] w-fit flex flex-col gap-1',\n props.isOwnMessage ? 'items-end' : '',\n])\n\nconst headerClasses = computed(() => [\n 'flex items-center gap-2 text-xs px-3',\n props.isOwnMessage ? 'justify-end flex-row-reverse' : '',\n])\n\nconst bubbleClasses = computed(() => [\n 'py-2 px-3 rounded-xl text-sm w-fit',\n props.isOwnMessage\n ? 'bg-primary text-primary-foreground'\n : 'bg-muted text-foreground',\n])\n\nconst formattedTime = computed(() =>\n new Date(props.message.createdAt).toLocaleTimeString('en-US', {\n hour: '2-digit',\n minute: '2-digit',\n hour12: true,\n })\n)\n</script>\n\n<template>\n <div :class=\"containerClasses\">\n <div :class=\"wrapperClasses\">\n <!-- Header -->\n <div v-if=\"showHeader\" :class=\"headerClasses\">\n <span class=\"font-medium\">\n {{ message.user.name }}\n </span>\n\n <span class=\"text-foreground/50 text-xs\">\n {{ formattedTime }}\n </span>\n </div>\n\n <!-- Message Bubble -->\n <div :class=\"bubbleClasses\">\n {{ message.content }}\n </div>\n </div>\n </div>\n</template>\n",
+ "type": "registry:component",
+ "target": "components/chat-message-item.vue"
+ },
+ {
+ "path": "registry/default/realtime-chat/vue/composables/useChatScroll.ts",
+ "content": "import { ref } from 'vue'\n\nexport function useChatScroll() {\n const containerRef = ref<HTMLDivElement | null>(null)\n\n function scrollToBottom() {\n if (!containerRef.value) return\n\n const container = containerRef.value\n\n container.scrollTo({\n top: container.scrollHeight,\n behavior: 'smooth',\n })\n }\n\n return {\n containerRef,\n scrollToBottom,\n }\n}\n",
+ "type": "registry:component",
+ "target": "composables/useChatScroll.ts"
+ },
+ {
+ "path": "registry/default/realtime-chat/vue/composables/useRealtimeChat.ts",
+ "content": "import { onUnmounted, ref, watch } from 'vue'\n\n// @ts-ignore\nimport { createClient } from '@/lib/supabase/client'\n\ninterface UseRealtimeChatProps {\n roomName: string\n username: string\n}\n\nexport interface ChatMessage {\n id: string\n content: string\n user: {\n name: string\n }\n createdAt: string\n}\n\nconst EVENT_MESSAGE_TYPE = 'message'\n\nexport function useRealtimeChat(props: UseRealtimeChatProps) {\n const supabase = createClient()\n\n const messages = ref<ChatMessage[]>([])\n const channel = ref<ReturnType<typeof supabase.channel> | null>(null)\n const isConnected = ref(false)\n\n function cleanup() {\n if (channel.value) {\n supabase.removeChannel(channel.value)\n channel.value = null\n }\n }\n\n function setupChannel() {\n if (!props.roomName) return\n\n const newChannel = supabase.channel(props.roomName)\n\n newChannel\n .on('broadcast', { event: EVENT_MESSAGE_TYPE }, (payload: { payload: ChatMessage }) => {\n messages.value.push(payload.payload as ChatMessage)\n })\n .subscribe((status: string) => {\n isConnected.value = status === 'SUBSCRIBED'\n })\n\n channel.value = newChannel\n }\n\n watch(\n () => props.roomName,\n () => {\n cleanup()\n setupChannel()\n },\n { immediate: true }\n )\n\n onUnmounted(() => {\n cleanup()\n })\n\n async function sendMessage(content: string) {\n if (!channel.value || !isConnected.value) return\n\n const message: ChatMessage = {\n id: crypto.randomUUID(),\n content,\n user: {\n name: props.username,\n },\n createdAt: new Date().toISOString(),\n }\n\n // Optimistic update\n messages.value.push(message)\n\n await channel.value.send({\n type: 'broadcast',\n event: EVENT_MESSAGE_TYPE,\n payload: message,\n })\n }\n\n return {\n messages,\n sendMessage,\n isConnected,\n }\n}\n",
+ "type": "registry:component",
+ "target": "composables/useRealtimeChat.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 f9168973a6d..f6785bf6c4b 100644
--- a/apps/ui-library/public/r/registry.json
+++ b/apps/ui-library/public/r/registry.json
@@ -2406,6 +2406,95 @@
"@supabase/supabase-js@latest"
]
},
+ {
+ "name": "realtime-chat-nuxtjs",
+ "type": "registry:block",
+ "title": "Realtime Chat",
+ "description": "Component which provides a realtime chat interface.",
+ "registryDependencies": [
+ "button",
+ "input"
+ ],
+ "files": [
+ {
+ "path": "registry/default/realtime-chat/nuxtjs/app/components/realtime-chat.vue",
+ "type": "registry:component",
+ "target": "app/components/realtime-chat.vue"
+ },
+ {
+ "path": "registry/default/realtime-chat/nuxtjs/app/components/chat-message-item.vue",
+ "type": "registry:component",
+ "target": "app/components/chat-message-item.vue"
+ },
+ {
+ "path": "registry/default/realtime-chat/nuxtjs/app/composables/useChatScroll.ts",
+ "type": "registry:component",
+ "target": "app/composables/useChatScroll.ts"
+ },
+ {
+ "path": "registry/default/realtime-chat/nuxtjs/app/composables/useRealtimeChat.ts",
+ "type": "registry:component",
+ "target": "app/composables/useRealtimeChat.ts"
+ }
+ ],
+ "dependencies": [
+ "@supabase/supabase-js@latest",
+ "lucide-vue-next@latest"
+ ]
+ },
+ {
+ "name": "realtime-chat-vue",
+ "type": "registry:block",
+ "title": "Realtime Chat",
+ "description": "Component which provides a realtime chat interface.",
+ "registryDependencies": [
+ "button",
+ "input"
+ ],
+ "files": [
+ {
+ "path": "registry/default/realtime-chat/vue/components/realtime-chat.vue",
+ "type": "registry:component",
+ "target": "components/realtime-chat.vue"
+ },
+ {
+ "path": "registry/default/realtime-chat/vue/components/chat-message-item.vue",
+ "type": "registry:component",
+ "target": "components/chat-message-item.vue"
+ },
+ {
+ "path": "registry/default/realtime-chat/vue/composables/useChatScroll.ts",
+ "type": "registry:component",
+ "target": "composables/useChatScroll.ts"
+ },
+ {
+ "path": "registry/default/realtime-chat/vue/composables/useRealtimeChat.ts",
+ "type": "registry:component",
+ "target": "composables/useRealtimeChat.ts"
+ }
+ ],
+ "dependencies": [
+ "@supabase/supabase-js@latest",
+ "lucide-vue-next@latest"
+ ]
+ },
+ {
+ "name": "infinite-query-composable",
+ "type": "registry:component",
+ "title": "Infinite Query for Vue and Supabase",
+ "description": "Vue Composable for infinite lists, fetching data from Supabase.",
+ "files": [
+ {
+ "path": "registry/default/infinite-query/vue/composables/useInfiniteQuery.ts",
+ "type": "registry:component",
+ "target": "composables/useInfiniteQuery.ts"
+ }
+ ],
+ "dependencies": [
+ "@supabase/supabase-js@latest",
+ "@supabase/postgrest-js@*"
+ ]
+ },
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "ai-editor-rules",
diff --git a/blocks/vue/package.json b/blocks/vue/package.json
index 86649e56037..15fa3ed73f7 100644
--- a/blocks/vue/package.json
+++ b/blocks/vue/package.json
@@ -10,6 +10,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
+ "@supabase/postgrest-js": "catalog:",
"@supabase/ssr": "catalog:",
"@supabase/supabase-js": "catalog:",
"@vueuse/core": "^14.1.0",
diff --git a/blocks/vue/registry/default/infinite-query/vue/composables/useInfiniteQuery.ts b/blocks/vue/registry/default/infinite-query/vue/composables/useInfiniteQuery.ts
new file mode 100644
index 00000000000..c6d6e9152a7
--- /dev/null
+++ b/blocks/vue/registry/default/infinite-query/vue/composables/useInfiniteQuery.ts
@@ -0,0 +1,187 @@
+import { PostgrestQueryBuilder, type PostgrestClientOptions } from '@supabase/postgrest-js'
+import { type SupabaseClient } from '@supabase/supabase-js'
+import { computed, onMounted, reactive, toRefs, watch } from 'vue'
+
+// @ts-ignore
+import { createClient } from '@/lib/supabase/client'
+
+const supabase = createClient()
+
+type SupabaseClientType = typeof supabase
+
+type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N
+
+type Database =
+ SupabaseClientType extends SupabaseClient<infer U>
+ ? IfAny<
+ U,
+ {
+ public: {
+ Tables: Record<string, any>
+ Views: Record<string, any>
+ Functions: Record<string, any>
+ }
+ },
+ U
+ >
+ : {
+ public: {
+ Tables: Record<string, any>
+ Views: Record<string, any>
+ Functions: Record<string, any>
+ }
+ }
+
+type DatabaseSchema = Database['public']
+type SupabaseTableName = keyof DatabaseSchema['Tables']
+type SupabaseTableData<T extends SupabaseTableName> = DatabaseSchema['Tables'][T]['Row']
+
+type DefaultClientOptions = PostgrestClientOptions
+
+type SupabaseSelectBuilder<T extends SupabaseTableName> = ReturnType<
+ PostgrestQueryBuilder<
+ DefaultClientOptions,
+ DatabaseSchema,
+ DatabaseSchema['Tables'][T],
+ T
+ >['select']
+>
+
+export type SupabaseQueryHandler<T extends SupabaseTableName> = (
+ query: SupabaseSelectBuilder<T>
+) => SupabaseSelectBuilder<T>
+
+export interface UseInfiniteQueryProps<T extends SupabaseTableName> {
+ tableName: T
+ columns?: string
+ pageSize?: number
+ trailingQuery?: SupabaseQueryHandler<T>
+}
+
+interface State<TData> {
+ data: TData[]
+ count: number
+ isSuccess: boolean
+ isLoading: boolean
+ isFetching: boolean
+ error: Error | null
+ hasInitialFetch: boolean
+ requestCounter: number
+}
+
+// --------------------
+// Composable
+// --------------------
+
+export function useInfiniteQuery<
+ TData extends SupabaseTableData<T>,
+ T extends SupabaseTableName = SupabaseTableName,
+>(props: UseInfiniteQueryProps<T>) {
+ const state = reactive<State<TData>>({
+ data: [],
+ count: 0,
+ isSuccess: false,
+ isLoading: false,
+ isFetching: false,
+ error: null,
+ hasInitialFetch: false,
+ requestCounter: 0,
+ })
+
+ const pageSize = computed(() => props.pageSize ?? 20)
+ const columns = computed(() => props.columns ?? '*')
+
+ const fetchPage = async (skip: number) => {
+ // Capture the current request token to validate this request later
+ const requestToken = state.requestCounter
+
+ if (state.hasInitialFetch && (state.isFetching || state.data.length >= state.count)) {
+ return
+ }
+
+ // Early return if request has been invalidated
+ if (requestToken !== state.requestCounter) {
+ return
+ }
+
+ state.isFetching = true
+
+ let query = supabase
+ .from(props.tableName)
+ .select(columns.value, { count: 'exact' }) as unknown as SupabaseSelectBuilder<T>
+
+ if (props.trailingQuery) {
+ query = props.trailingQuery(query)
+ }
+
+ const { data, count, error } = await query.range(skip, skip + pageSize.value - 1)
+
+ // Verify that this request is still valid before mutating state
+ if (requestToken !== state.requestCounter) {
+ state.isFetching = false
+ return
+ }
+
+ if (error) {
+ console.error(error)
+ state.error = error
+ } else {
+ state.data.push(...(data as TData[]))
+ state.count = count || 0
+ state.isSuccess = true
+ state.error = null
+ }
+
+ state.isFetching = false
+ }
+
+ const fetchNextPage = async () => {
+ if (state.isFetching) return
+ await fetchPage(state.data.length)
+ }
+
+ const reset = () => {
+ state.data = []
+ state.count = 0
+ state.isSuccess = false
+ state.error = null
+ state.hasInitialFetch = false
+ state.isFetching = false
+ state.requestCounter++
+ }
+
+ const initialize = async () => {
+ state.isLoading = true
+ reset()
+
+ await fetchNextPage()
+
+ state.isLoading = false
+ state.hasInitialFetch = true
+ }
+
+ // React-style deps → Vue watch
+ watch(
+ () => [props.tableName, props.columns, props.pageSize],
+ () => {
+ if (state.hasInitialFetch) {
+ initialize()
+ }
+ }
+ )
+
+ onMounted(() => {
+ if (!state.hasInitialFetch) {
+ initialize()
+ }
+ })
+
+ const hasMore = computed(() => state.count > state.data.length)
+
+ return {
+ ...toRefs(state),
+ hasMore,
+ fetchNextPage,
+ refresh: initialize,
+ }
+}
diff --git a/blocks/vue/registry/default/infinite-query/vue/registry-item.json b/blocks/vue/registry/default/infinite-query/vue/registry-item.json
new file mode 100644
index 00000000000..8cea2bbad60
--- /dev/null
+++ b/blocks/vue/registry/default/infinite-query/vue/registry-item.json
@@ -0,0 +1,14 @@
+{
+ "name": "infinite-query-composable",
+ "type": "registry:component",
+ "title": "Infinite Query for Vue and Supabase",
+ "description": "Vue Composable for infinite lists, fetching data from Supabase.",
+ "files": [
+ {
+ "path": "registry/default/infinite-query/vue/composables/useInfiniteQuery.ts",
+ "type": "registry:component",
+ "target": "composables/useInfiniteQuery.ts"
+ }
+ ],
+ "dependencies": ["@supabase/supabase-js@latest", "@supabase/postgrest-js@*"]
+}
diff --git a/blocks/vue/registry/default/realtime-chat/nuxtjs/app/components/chat-message-item.vue b/blocks/vue/registry/default/realtime-chat/nuxtjs/app/components/chat-message-item.vue
new file mode 100644
index 00000000000..a2c7453c85f
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-chat/nuxtjs/app/components/chat-message-item.vue
@@ -0,0 +1,62 @@
+<script setup lang="ts">
+import { computed } from 'vue'
+import type { ChatMessage } from '../composables/useRealtimeChat'
+
+const props = defineProps<{
+ message: ChatMessage
+ isOwnMessage: boolean
+ showHeader: boolean
+}>()
+
+const containerClasses = computed(() => [
+ 'flex mt-2',
+ props.isOwnMessage ? 'justify-end' : 'justify-start',
+])
+
+const wrapperClasses = computed(() => [
+ 'max-w-[75%] w-fit flex flex-col gap-1',
+ props.isOwnMessage ? 'items-end' : '',
+])
+
+const headerClasses = computed(() => [
+ 'flex items-center gap-2 text-xs px-3',
+ props.isOwnMessage ? 'justify-end flex-row-reverse' : '',
+])
+
+const bubbleClasses = computed(() => [
+ 'py-2 px-3 rounded-xl text-sm w-fit',
+ props.isOwnMessage
+ ? 'bg-primary text-primary-foreground'
+ : 'bg-muted text-foreground',
+])
+
+const formattedTime = computed(() =>
+ new Date(props.message.createdAt).toLocaleTimeString('en-US', {
+ hour: '2-digit',
+ minute: '2-digit',
+ hour12: true,
+ })
+)
+</script>
+
+<template>
+ <div :class="containerClasses">
+ <div :class="wrapperClasses">
+ <!-- Header -->
+ <div v-if="showHeader" :class="headerClasses">
+ <span class="font-medium">
+ {{ message.user.name }}
+ </span>
+
+ <span class="text-foreground/50 text-xs">
+ {{ formattedTime }}
+ </span>
+ </div>
+
+ <!-- Message Bubble -->
+ <div :class="bubbleClasses">
+ {{ message.content }}
+ </div>
+ </div>
+ </div>
+</template>
diff --git a/blocks/vue/registry/default/realtime-chat/nuxtjs/app/components/realtime-chat.vue b/blocks/vue/registry/default/realtime-chat/nuxtjs/app/components/realtime-chat.vue
new file mode 100644
index 00000000000..b6469cfb21a
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-chat/nuxtjs/app/components/realtime-chat.vue
@@ -0,0 +1,132 @@
+<script setup lang="ts">
+import { ref, computed, watch } from 'vue'
+import { Send } from 'lucide-vue-next'
+
+import ChatMessageItem from './chat-message-item.vue'
+import { useChatScroll } from '../composables/useChatScroll'
+import {
+ useRealtimeChat,
+ type ChatMessage,
+} from '../composables/useRealtimeChat'
+ // @ts-ignore
+import Button from '@/components/ui/Button.vue'
+ // @ts-ignore
+import Input from '@/components/ui/Input.vue'
+
+interface RealtimeChatProps {
+ roomName: string
+ username: string
+ onMessage?: (messages: ChatMessage[]) => void
+ messages?: ChatMessage[]
+}
+
+const props = defineProps<RealtimeChatProps>()
+
+const initialMessages = computed(() => props.messages ?? [])
+
+const { containerRef, scrollToBottom } = useChatScroll()
+
+const { messages: realtimeMessages, sendMessage, isConnected } =
+ useRealtimeChat({
+ roomName: props.roomName,
+ username: props.username,
+ })
+
+const newMessage = ref('')
+
+/**
+ * Merge + dedupe + sort
+ */
+const allMessages = computed<ChatMessage[]>(() => {
+ const merged = [...initialMessages.value, ...realtimeMessages.value]
+
+ const unique = merged.filter(
+ (message, index, self) =>
+ index === self.findIndex((m) => m.id === message.id)
+ )
+
+ return unique.sort((a, b) =>
+ a.createdAt.localeCompare(b.createdAt)
+ )
+})
+
+/**
+ * Emit messages to parent if callback provided
+ */
+watch(allMessages, (messages) => {
+ if (props.onMessage) {
+ props.onMessage(messages)
+ }
+
+ scrollToBottom()
+}, { flush: 'post' })
+
+function handleSendMessage() {
+ if (!newMessage.value.trim() || !isConnected.value) return
+
+ sendMessage(newMessage.value)
+ newMessage.value = ''
+}
+</script>
+
+<template>
+ <div class="flex flex-col h-full w-full bg-background text-foreground antialiased">
+ <!-- Messages -->
+ <div
+ ref="containerRef"
+ class="flex-1 overflow-y-auto p-4 space-y-4"
+ >
+ <div
+ v-if="allMessages.length === 0"
+ class="text-center text-sm text-muted-foreground"
+ >
+ No messages yet. Start the conversation!
+ </div>
+
+ <div class="space-y-1">
+ <div
+ v-for="(message, index) in allMessages"
+ :key="message.id"
+ class="animate-in fade-in slide-in-from-bottom-4 duration-300"
+ >
+ <ChatMessageItem
+ :message="message"
+ :isOwnMessage="message.user.name === props.username"
+ :showHeader="
+ !allMessages[index - 1] ||
+ allMessages[index - 1].user.name !== message.user.name
+ "
+ />
+ </div>
+ </div>
+ </div>
+
+ <!-- Input -->
+ <form
+ @submit.prevent="handleSendMessage"
+ class="flex w-full gap-2 border-t border-border p-4"
+ >
+ <Input
+ v-model="newMessage"
+ :disabled="!isConnected"
+ type="text"
+ placeholder="Type a message..."
+ :class="[
+ 'rounded-full bg-background text-sm transition-all duration-300',
+ isConnected && newMessage.trim()
+ ? 'w-[calc(100%-36px)]'
+ : 'w-full',
+ ]"
+ />
+
+ <Button
+ v-if="isConnected && newMessage.trim()"
+ type="submit"
+ :disabled="!isConnected"
+ class="aspect-square rounded-full animate-in fade-in slide-in-from-right-4 duration-300"
+ >
+ <Send class="size-4" />
+ </Button>
+ </form>
+ </div>
+</template>
diff --git a/blocks/vue/registry/default/realtime-chat/nuxtjs/app/composables/useChatScroll.ts b/blocks/vue/registry/default/realtime-chat/nuxtjs/app/composables/useChatScroll.ts
new file mode 100644
index 00000000000..5ca670f1dc4
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-chat/nuxtjs/app/composables/useChatScroll.ts
@@ -0,0 +1,21 @@
+import { ref } from 'vue'
+
+export function useChatScroll() {
+ const containerRef = ref<HTMLDivElement | null>(null)
+
+ function scrollToBottom() {
+ if (!containerRef.value) return
+
+ const container = containerRef.value
+
+ container.scrollTo({
+ top: container.scrollHeight,
+ behavior: 'smooth',
+ })
+ }
+
+ return {
+ containerRef,
+ scrollToBottom,
+ }
+}
diff --git a/blocks/vue/registry/default/realtime-chat/nuxtjs/app/composables/useRealtimeChat.ts b/blocks/vue/registry/default/realtime-chat/nuxtjs/app/composables/useRealtimeChat.ts
new file mode 100644
index 00000000000..094caa2f201
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-chat/nuxtjs/app/composables/useRealtimeChat.ts
@@ -0,0 +1,92 @@
+import { onUnmounted, ref, watch } from 'vue'
+
+// @ts-ignore
+import { createClient } from '@/lib/supabase/client'
+
+interface UseRealtimeChatProps {
+ roomName: string
+ username: string
+}
+
+export interface ChatMessage {
+ id: string
+ content: string
+ user: {
+ name: string
+ }
+ createdAt: string
+}
+
+const EVENT_MESSAGE_TYPE = 'message'
+
+export function useRealtimeChat(props: UseRealtimeChatProps) {
+ const supabase = createClient()
+
+ const messages = ref<ChatMessage[]>([])
+ const channel = ref<ReturnType<typeof supabase.channel> | null>(null)
+ const isConnected = ref(false)
+
+ function cleanup() {
+ if (channel.value) {
+ supabase.removeChannel(channel.value)
+ channel.value = null
+ }
+ }
+
+ function setupChannel() {
+ if (!props.roomName) return
+
+ const newChannel = supabase.channel(props.roomName)
+
+ newChannel
+ .on('broadcast', { event: EVENT_MESSAGE_TYPE }, (payload: { payload: ChatMessage }) => {
+ messages.value.push(payload.payload as ChatMessage)
+ })
+ .subscribe((status: string) => {
+ isConnected.value = status === 'SUBSCRIBED'
+ })
+
+ channel.value = newChannel
+ }
+
+ watch(
+ () => props.roomName,
+ () => {
+ cleanup()
+ setupChannel()
+ },
+ { immediate: true }
+ )
+
+ onUnmounted(() => {
+ cleanup()
+ })
+
+ async function sendMessage(content: string) {
+ if (!channel.value || !isConnected.value) return
+
+ const message: ChatMessage = {
+ id: crypto.randomUUID(),
+ content,
+ user: {
+ name: props.username,
+ },
+ createdAt: new Date().toISOString(),
+ }
+
+ // Optimistic update
+ messages.value.push(message)
+
+ await channel.value.send({
+ type: 'broadcast',
+ event: EVENT_MESSAGE_TYPE,
+ payload: message,
+ })
+ }
+
+ return {
+ messages,
+ sendMessage,
+ isConnected,
+ }
+}
diff --git a/blocks/vue/registry/default/realtime-chat/nuxtjs/registry-item.json b/blocks/vue/registry/default/realtime-chat/nuxtjs/registry-item.json
new file mode 100644
index 00000000000..e0aabffb85d
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-chat/nuxtjs/registry-item.json
@@ -0,0 +1,30 @@
+{
+ "name": "realtime-chat-nuxtjs",
+ "type": "registry:block",
+ "title": "Realtime Chat",
+ "description": "Component which provides a realtime chat interface.",
+ "registryDependencies": ["button", "input"],
+ "files": [
+ {
+ "path": "registry/default/realtime-chat/nuxtjs/app/components/realtime-chat.vue",
+ "type": "registry:component",
+ "target": "app/components/realtime-chat.vue"
+ },
+ {
+ "path": "registry/default/realtime-chat/nuxtjs/app/components/chat-message-item.vue",
+ "type": "registry:component",
+ "target": "app/components/chat-message-item.vue"
+ },
+ {
+ "path": "registry/default/realtime-chat/nuxtjs/app/composables/useChatScroll.ts",
+ "type": "registry:component",
+ "target": "app/composables/useChatScroll.ts"
+ },
+ {
+ "path": "registry/default/realtime-chat/nuxtjs/app/composables/useRealtimeChat.ts",
+ "type": "registry:component",
+ "target": "app/composables/useRealtimeChat.ts"
+ }
+ ],
+ "dependencies": ["@supabase/supabase-js@latest", "lucide-vue-next@latest"]
+}
diff --git a/blocks/vue/registry/default/realtime-chat/vue/components/chat-message-item.vue b/blocks/vue/registry/default/realtime-chat/vue/components/chat-message-item.vue
new file mode 100644
index 00000000000..a2c7453c85f
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-chat/vue/components/chat-message-item.vue
@@ -0,0 +1,62 @@
+<script setup lang="ts">
+import { computed } from 'vue'
+import type { ChatMessage } from '../composables/useRealtimeChat'
+
+const props = defineProps<{
+ message: ChatMessage
+ isOwnMessage: boolean
+ showHeader: boolean
+}>()
+
+const containerClasses = computed(() => [
+ 'flex mt-2',
+ props.isOwnMessage ? 'justify-end' : 'justify-start',
+])
+
+const wrapperClasses = computed(() => [
+ 'max-w-[75%] w-fit flex flex-col gap-1',
+ props.isOwnMessage ? 'items-end' : '',
+])
+
+const headerClasses = computed(() => [
+ 'flex items-center gap-2 text-xs px-3',
+ props.isOwnMessage ? 'justify-end flex-row-reverse' : '',
+])
+
+const bubbleClasses = computed(() => [
+ 'py-2 px-3 rounded-xl text-sm w-fit',
+ props.isOwnMessage
+ ? 'bg-primary text-primary-foreground'
+ : 'bg-muted text-foreground',
+])
+
+const formattedTime = computed(() =>
+ new Date(props.message.createdAt).toLocaleTimeString('en-US', {
+ hour: '2-digit',
+ minute: '2-digit',
+ hour12: true,
+ })
+)
+</script>
+
+<template>
+ <div :class="containerClasses">
+ <div :class="wrapperClasses">
+ <!-- Header -->
+ <div v-if="showHeader" :class="headerClasses">
+ <span class="font-medium">
+ {{ message.user.name }}
+ </span>
+
+ <span class="text-foreground/50 text-xs">
+ {{ formattedTime }}
+ </span>
+ </div>
+
+ <!-- Message Bubble -->
+ <div :class="bubbleClasses">
+ {{ message.content }}
+ </div>
+ </div>
+ </div>
+</template>
diff --git a/blocks/vue/registry/default/realtime-chat/vue/components/realtime-chat.vue b/blocks/vue/registry/default/realtime-chat/vue/components/realtime-chat.vue
new file mode 100644
index 00000000000..b6469cfb21a
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-chat/vue/components/realtime-chat.vue
@@ -0,0 +1,132 @@
+<script setup lang="ts">
+import { ref, computed, watch } from 'vue'
+import { Send } from 'lucide-vue-next'
+
+import ChatMessageItem from './chat-message-item.vue'
+import { useChatScroll } from '../composables/useChatScroll'
+import {
+ useRealtimeChat,
+ type ChatMessage,
+} from '../composables/useRealtimeChat'
+ // @ts-ignore
+import Button from '@/components/ui/Button.vue'
+ // @ts-ignore
+import Input from '@/components/ui/Input.vue'
+
+interface RealtimeChatProps {
+ roomName: string
+ username: string
+ onMessage?: (messages: ChatMessage[]) => void
+ messages?: ChatMessage[]
+}
+
+const props = defineProps<RealtimeChatProps>()
+
+const initialMessages = computed(() => props.messages ?? [])
+
+const { containerRef, scrollToBottom } = useChatScroll()
+
+const { messages: realtimeMessages, sendMessage, isConnected } =
+ useRealtimeChat({
+ roomName: props.roomName,
+ username: props.username,
+ })
+
+const newMessage = ref('')
+
+/**
+ * Merge + dedupe + sort
+ */
+const allMessages = computed<ChatMessage[]>(() => {
+ const merged = [...initialMessages.value, ...realtimeMessages.value]
+
+ const unique = merged.filter(
+ (message, index, self) =>
+ index === self.findIndex((m) => m.id === message.id)
+ )
+
+ return unique.sort((a, b) =>
+ a.createdAt.localeCompare(b.createdAt)
+ )
+})
+
+/**
+ * Emit messages to parent if callback provided
+ */
+watch(allMessages, (messages) => {
+ if (props.onMessage) {
+ props.onMessage(messages)
+ }
+
+ scrollToBottom()
+}, { flush: 'post' })
+
+function handleSendMessage() {
+ if (!newMessage.value.trim() || !isConnected.value) return
+
+ sendMessage(newMessage.value)
+ newMessage.value = ''
+}
+</script>
+
+<template>
+ <div class="flex flex-col h-full w-full bg-background text-foreground antialiased">
+ <!-- Messages -->
+ <div
+ ref="containerRef"
+ class="flex-1 overflow-y-auto p-4 space-y-4"
+ >
+ <div
+ v-if="allMessages.length === 0"
+ class="text-center text-sm text-muted-foreground"
+ >
+ No messages yet. Start the conversation!
+ </div>
+
+ <div class="space-y-1">
+ <div
+ v-for="(message, index) in allMessages"
+ :key="message.id"
+ class="animate-in fade-in slide-in-from-bottom-4 duration-300"
+ >
+ <ChatMessageItem
+ :message="message"
+ :isOwnMessage="message.user.name === props.username"
+ :showHeader="
+ !allMessages[index - 1] ||
+ allMessages[index - 1].user.name !== message.user.name
+ "
+ />
+ </div>
+ </div>
+ </div>
+
+ <!-- Input -->
+ <form
+ @submit.prevent="handleSendMessage"
+ class="flex w-full gap-2 border-t border-border p-4"
+ >
+ <Input
+ v-model="newMessage"
+ :disabled="!isConnected"
+ type="text"
+ placeholder="Type a message..."
+ :class="[
+ 'rounded-full bg-background text-sm transition-all duration-300',
+ isConnected && newMessage.trim()
+ ? 'w-[calc(100%-36px)]'
+ : 'w-full',
+ ]"
+ />
+
+ <Button
+ v-if="isConnected && newMessage.trim()"
+ type="submit"
+ :disabled="!isConnected"
+ class="aspect-square rounded-full animate-in fade-in slide-in-from-right-4 duration-300"
+ >
+ <Send class="size-4" />
+ </Button>
+ </form>
+ </div>
+</template>
diff --git a/blocks/vue/registry/default/realtime-chat/vue/composables/useChatScroll.ts b/blocks/vue/registry/default/realtime-chat/vue/composables/useChatScroll.ts
new file mode 100644
index 00000000000..5ca670f1dc4
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-chat/vue/composables/useChatScroll.ts
@@ -0,0 +1,21 @@
+import { ref } from 'vue'
+
+export function useChatScroll() {
+ const containerRef = ref<HTMLDivElement | null>(null)
+
+ function scrollToBottom() {
+ if (!containerRef.value) return
+
+ const container = containerRef.value
+
+ container.scrollTo({
+ top: container.scrollHeight,
+ behavior: 'smooth',
+ })
+ }
+
+ return {
+ containerRef,
+ scrollToBottom,
+ }
+}
diff --git a/blocks/vue/registry/default/realtime-chat/vue/composables/useRealtimeChat.ts b/blocks/vue/registry/default/realtime-chat/vue/composables/useRealtimeChat.ts
new file mode 100644
index 00000000000..094caa2f201
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-chat/vue/composables/useRealtimeChat.ts
@@ -0,0 +1,92 @@
+import { onUnmounted, ref, watch } from 'vue'
+
+// @ts-ignore
+import { createClient } from '@/lib/supabase/client'
+
+interface UseRealtimeChatProps {
+ roomName: string
+ username: string
+}
+
+export interface ChatMessage {
+ id: string
+ content: string
+ user: {
+ name: string
+ }
+ createdAt: string
+}
+
+const EVENT_MESSAGE_TYPE = 'message'
+
+export function useRealtimeChat(props: UseRealtimeChatProps) {
+ const supabase = createClient()
+
+ const messages = ref<ChatMessage[]>([])
+ const channel = ref<ReturnType<typeof supabase.channel> | null>(null)
+ const isConnected = ref(false)
+
+ function cleanup() {
+ if (channel.value) {
+ supabase.removeChannel(channel.value)
+ channel.value = null
+ }
+ }
+
+ function setupChannel() {
+ if (!props.roomName) return
+
+ const newChannel = supabase.channel(props.roomName)
+
+ newChannel
+ .on('broadcast', { event: EVENT_MESSAGE_TYPE }, (payload: { payload: ChatMessage }) => {
+ messages.value.push(payload.payload as ChatMessage)
+ })
+ .subscribe((status: string) => {
+ isConnected.value = status === 'SUBSCRIBED'
+ })
+
+ channel.value = newChannel
+ }
+
+ watch(
+ () => props.roomName,
+ () => {
+ cleanup()
+ setupChannel()
+ },
+ { immediate: true }
+ )
+
+ onUnmounted(() => {
+ cleanup()
+ })
+
+ async function sendMessage(content: string) {
+ if (!channel.value || !isConnected.value) return
+
+ const message: ChatMessage = {
+ id: crypto.randomUUID(),
+ content,
+ user: {
+ name: props.username,
+ },
+ createdAt: new Date().toISOString(),
+ }
+
+ // Optimistic update
+ messages.value.push(message)
+
+ await channel.value.send({
+ type: 'broadcast',
+ event: EVENT_MESSAGE_TYPE,
+ payload: message,
+ })
+ }
+
+ return {
+ messages,
+ sendMessage,
+ isConnected,
+ }
+}
diff --git a/blocks/vue/registry/default/realtime-chat/vue/registry-item.json b/blocks/vue/registry/default/realtime-chat/vue/registry-item.json
new file mode 100644
index 00000000000..1616512c2d7
--- /dev/null
+++ b/blocks/vue/registry/default/realtime-chat/vue/registry-item.json
@@ -0,0 +1,30 @@
+{
+ "name": "realtime-chat-vue",
+ "type": "registry:block",
+ "title": "Realtime Chat",
+ "description": "Component which provides a realtime chat interface.",
+ "registryDependencies": ["button", "input"],
+ "files": [
+ {
+ "path": "registry/default/realtime-chat/vue/components/realtime-chat.vue",
+ "type": "registry:component",
+ "target": "components/realtime-chat.vue"
+ },
+ {
+ "path": "registry/default/realtime-chat/vue/components/chat-message-item.vue",
+ "type": "registry:component",
+ "target": "components/chat-message-item.vue"
+ },
+ {
+ "path": "registry/default/realtime-chat/vue/composables/useChatScroll.ts",
+ "type": "registry:component",
+ "target": "composables/useChatScroll.ts"
+ },
+ {
+ "path": "registry/default/realtime-chat/vue/composables/useRealtimeChat.ts",
+ "type": "registry:component",
+ "target": "composables/useRealtimeChat.ts"
+ }
+ ],
+ "dependencies": ["@supabase/supabase-js@latest", "lucide-vue-next@latest"]
+}
diff --git a/blocks/vue/registry/index.ts b/blocks/vue/registry/index.ts
index 5493d9b8a46..4c53e55a213 100644
--- a/blocks/vue/registry/index.ts
+++ b/blocks/vue/registry/index.ts
@@ -1,10 +1,12 @@
import { clients } from './clients'
+import { currentUserAvatar } from './current-user-avatar'
import { dropzone } from './dropzone'
+import { infiniteQuery } from './infinite-query'
import { passwordBasedAuth } from './password-based-auth'
+import { realtimeAvatarStack } from './realtime-avatar-stack'
+import { realtimeChat } from './realtime-chat'
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,
@@ -14,6 +16,8 @@ const blocks = [
...realtimeCursor,
...currentUserAvatar,
...realtimeAvatarStack,
+ ...realtimeChat,
+ ...infiniteQuery,
]
export { blocks }
diff --git a/blocks/vue/registry/infinite-query.ts b/blocks/vue/registry/infinite-query.ts
new file mode 100644
index 00000000000..16e8eb8477b
--- /dev/null
+++ b/blocks/vue/registry/infinite-query.ts
@@ -0,0 +1,5 @@
+import { type Registry } from 'shadcn/schema'
+
+import vue from './default/infinite-query/vue/registry-item.json' with { type: 'json' }
+
+export const infiniteQuery = [vue] as Registry['items']
diff --git a/blocks/vue/registry/realtime-chat.ts b/blocks/vue/registry/realtime-chat.ts
new file mode 100644
index 00000000000..bb01c123b6e
--- /dev/null
+++ b/blocks/vue/registry/realtime-chat.ts
@@ -0,0 +1,6 @@
+import { type RegistryItem } from 'shadcn/schema'
+
+import nuxtjs from './default/realtime-chat/nuxtjs/registry-item.json' with { type: 'json' }
+import vue from './default/realtime-chat/vue/registry-item.json' with { type: 'json' }
+
+export const realtimeChat = [nuxtjs, vue] as RegistryItem[]
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a7c2dacf181..b548120ac98 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1892,6 +1892,9 @@ importers:
blocks/vue:
dependencies:
+ '@supabase/postgrest-js':
+ specifier: 'catalog:'
+ version: 2.106.0
'@supabase/ssr':
specifier: 'catalog:'
version: 0.10.2(@supabase/[email protected])