mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Problem After #53183 and #52567 have been addressed, we should strengthen the interconnections between the UI library and the rest of the Supabase ecosystem. ## Solution - Adds contextual links for `/library`, Auth / Realtime category pages, and specific Auth / Realtime components. Hits top-level product pages, docs, kb, and blogs. ## Preview links N/A, link changes are relatively atomic so easier to review without many preview links. --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
65 lines
3.0 KiB
Plaintext
65 lines
3.0 KiB
Plaintext
---
|
|
title: Realtime Cursor
|
|
description: Real-time cursor sharing for collaborative applications
|
|
preview: |-
|
|
<BlockOverview name="realtime-cursor-tanstack" showFiles>
|
|
<div className="flex flex-row -space-x-px w-full">
|
|
<BlockPreview name="realtime-cursor-demo" isPair />
|
|
<BlockPreview name="realtime-cursor-demo" isPair />
|
|
</div>
|
|
</BlockOverview>
|
|
---
|
|
|
|
## Installation
|
|
|
|
<BlockItem name="realtime-cursor-tanstack" />
|
|
|
|
## Introduction
|
|
|
|
The Realtime Cursors component lets users share their cursor position with others in the same room—perfect for real-time collaboration. It handles all the setup and boilerplate for you, so you can add it to your app with minimal effort.
|
|
|
|
**Features**
|
|
|
|
- Broadcast cursor position to other users in the same room
|
|
- Customizable cursor appearance
|
|
- Presence detection (automatically joins/leaves users)
|
|
- Low-latency updates using Supabase Realtime
|
|
- Room-based isolation for scoped collaboration
|
|
|
|
## Usage
|
|
|
|
The Realtime Cursor component is designed to be used in a room. It can be used to build real-time collaborative applications. Add the `<RealtimeCursors />` component to your page and it will render realtime cursors from other users in the room.
|
|
|
|
```tsx
|
|
import { RealtimeCursors } from '@/components/realtime-cursors'
|
|
|
|
export default function Page() {
|
|
return (
|
|
<div className="w-full min-h-screen">
|
|
<RealtimeCursors roomName="macrodata_refinement_office" username="Mark Scout" />
|
|
</div>
|
|
)
|
|
}
|
|
```
|
|
|
|
## Props
|
|
|
|
| Prop | Type | Description |
|
|
| ---------- | -------- | ---------------------------------------------------------- |
|
|
| `roomName` | `string` | Unique identifier for the shared room or session. |
|
|
| `username` | `string` | Name of the current user; used to track and label cursors. |
|
|
|
|
## Further reading
|
|
|
|
- [Realtime Broadcast](https://supabase.com/docs/guides/realtime/broadcast)
|
|
- [Realtime authorization](https://supabase.com/docs/guides/realtime/authorization)
|
|
- [Getting started with Realtime](https://supabase.com/docs/guides/realtime/getting_started)
|
|
- [Realtime limits](https://supabase.com/docs/guides/realtime/limits)
|
|
- [Realtime message usage and billing](https://supabase.com/docs/guides/platform/manage-your-usage/realtime-messages)
|
|
- [Row Level Security](https://supabase.com/docs/guides/database/postgres/row-level-security)
|
|
- [multiplayer.dev, a live Realtime demo](https://multiplayer.dev)
|
|
|
|
### Smoother cursors
|
|
|
|
While our Realtime Cursor component aims to keep things simple and lightweight, you may want to add smoother cursor animations for a more polished experience. Libraries like [perfect-cursors](https://github.com/steveruizok/perfect-cursors) can be integrated to add sophisticated interpolation between cursor positions. This is especially useful when dealing with network latency, as it creates fluid cursor movements even when position updates are received at longer intervals (e.g., every 50-80ms). The library handles the complex math of creating natural-looking cursor paths while maintaining performance.
|