mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Feature — the visual redesign itself. Part 5 of 6 in a stack that splits the library redesign into reviewable pieces. The four PRs beneath it carry the build, content and Markdown work; what's left here is layout, navigation and styling. ## What is the current behavior? The library is laid out like a documentation site: a sidebar tree of framework folders, a homepage that lists links, and a guide page that opens with prose. That shape suits reference material, but the library's job is to help someone find a block and install it — and the sidebar is the only way to discover one. ## What is the new behavior? The homepage is the catalog itself — blocks grouped by what they do (authentication, database, storage, realtime, messaging, AI, foundations) rather than by framework, each with a preview of what it renders, filterable by category. Navigation moves into a site header whose Explore menu opens the same categories, so the catalog is reachable from any page and the per-page sidebar tree is gone. A guide opens with what the reader came for: the block's name, the install command, and a preview pane with tabs — the running component and its files — before any prose. The file tree that used to sit mid-page under "Folder structure" is one of those tabs. Every guide also offers a copy of the agent prompt that points at its Markdown. Getting-started pages get the same treatment: the quickstart is now a framework-tabbed walkthrough rather than a wall of setup links. ## Additional context `BlockOverviewTabs` renders Preview and Files here. #50369, stacked on top of this one, adds the third "What's added" tab — it is the only part of the redesign that depends on the new resource analyzer, which is why it sits above this PR rather than below it. Also removes what the redesign orphaned: the table-of-contents component and its `remark` / `mdast-util-toc` dependencies, and the sidebar nav and command-item configuration the new header replaced. The block source changes are typography only — auth card titles move from `text-2xl` to `font-medium text-lg tracking-normal` — which is what regenerates the auth registry artifacts. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a redesigned Supabase Library catalog with categorized blocks, framework-aware navigation, previews, file views, and installation actions. * Added framework-specific quickstart guides for Next.js, React, Vue, Nuxt, React Router, and TanStack Start. * Added copy-to-clipboard prompts, “Open in v0” actions, starter templates, and richer visual previews. * **Improvements** * Updated documentation layouts, FAQ content, typography, navigation, accessibility, and responsive behavior. * Improved mobile navigation, framework selection, and standardized block installation guidance. * Refined authentication and social-login block presentation with more consistent heading styles. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
120 lines
5.6 KiB
Plaintext
120 lines
5.6 KiB
Plaintext
---
|
|
title: Realtime Monaco
|
|
description: Real-time Monaco editor for collaborative applications
|
|
preview: |-
|
|
<BlockOverview name="realtime-monaco-react-router" showFiles>
|
|
<DualRealtimeMonaco />
|
|
</BlockOverview>
|
|
---
|
|
|
|
## Installation
|
|
|
|
<BlockItem name="realtime-monaco-react-router" />
|
|
|
|
## Introduction
|
|
|
|
The Realtime Monaco component provides a collaborative code editor powered by [Monaco](https://microsoft.github.io/monaco-editor/) and [Yjs](https://yjs.dev/). It uses [`@supabase-labs/y-supabase`](https://github.com/supabase-community/y-supabase) under the hood to sync document state across clients through Supabase Realtime.
|
|
|
|
**Features**
|
|
|
|
- Real-time document synchronization via Supabase Realtime broadcast
|
|
- Cursor and selection sharing between collaborators (awareness)
|
|
- Optional persistence to Postgres so documents survive page reloads
|
|
- Supports all Monaco languages and themes
|
|
- Room-based isolation for scoped collaboration
|
|
|
|
## How it works under the hood
|
|
|
|
The component creates a [Yjs](https://yjs.dev/) document and connects it to a Supabase Realtime channel using `SupabaseProvider` from `@supabase-labs/y-supabase`. A `MonacoBinding` from `y-monaco` bridges the Yjs document with the Monaco editor model, keeping them in sync.
|
|
|
|
When **awareness** is enabled, each user's cursor position and selection are broadcast to other clients in the same channel. Remote cursors are rendered with unique colors via dynamically injected CSS.
|
|
|
|
When **persistence** is enabled, the full Yjs document state is saved to a Postgres table so it can be restored when clients reconnect.
|
|
|
|
## Usage
|
|
|
|
### Basic usage
|
|
|
|
```tsx
|
|
import { RealtimeMonaco } from '@/components/realtime-monaco'
|
|
|
|
export default function MonacoPage() {
|
|
return <RealtimeMonaco channel="realtime-monaco-demo" language="typescript" />
|
|
}
|
|
```
|
|
|
|
### With persistence
|
|
|
|
Enable persistence to save the editor content to your Supabase database. This requires a table to store the Yjs document state.
|
|
|
|
First, create the required table in your Supabase project:
|
|
|
|
```sql
|
|
create table yjs_documents (
|
|
room text primary key,
|
|
state text not null
|
|
);
|
|
```
|
|
|
|
Then pass `persistence` to the component:
|
|
|
|
```tsx
|
|
import { RealtimeMonaco } from '@/components/realtime-monaco'
|
|
|
|
export default function MonacoPage() {
|
|
return <RealtimeMonaco channel="realtime-monaco-demo" language="typescript" persistence />
|
|
}
|
|
```
|
|
|
|
You can also pass a `SupabasePersistenceOptions` object:
|
|
|
|
```tsx
|
|
<RealtimeMonaco
|
|
channel="realtime-monaco-demo"
|
|
language="typescript"
|
|
persistence={{
|
|
table: 'yjs_documents',
|
|
roomColumn: 'room',
|
|
stateColumn: 'state',
|
|
storeTimeout: 2000,
|
|
}}
|
|
/>
|
|
```
|
|
|
|
### Without awareness
|
|
|
|
By default, cursor and selection positions are shared between collaborators. To disable this:
|
|
|
|
```tsx
|
|
<RealtimeMonaco channel="realtime-monaco-demo" awareness={false} />
|
|
```
|
|
|
|
## Props
|
|
|
|
| Prop | Type | Description |
|
|
| -------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| `channel` | `string` | Unique channel name used to sync editor content between collaborators in the same session. |
|
|
| `language?` | `string` | Monaco [language identifier](https://code.visualstudio.com/docs/languages/identifiers) (e.g. `typescript`, `python`). Defaults to `javascript`. |
|
|
| `height?` | `string \| number` | Height of the editor container. Accepts a pixel number or CSS string (e.g. `"100%"`). Defaults to `550`. |
|
|
| `className?` | `string` | CSS class applied to the editor wrapper element. |
|
|
| `awareness?` | `boolean \| Awareness` | Enables cursor and selection sharing between users. Pass `false` to disable or a custom `Awareness` instance. Defaults to `true`. |
|
|
| `persistence?` | `boolean \| SupabasePersistenceOptions` | Persists editor content to Supabase so it survives page reloads. Pass `true` for defaults or an options object for fine-grained control. |
|
|
| `theme?` | `'light' \| 'dark'` | Color theme for the editor. Maps to Monaco's `light` and `vs-dark` themes. |
|
|
|
|
### SupabasePersistenceOptions
|
|
|
|
| Option | Type | Default | Description |
|
|
| -------------- | -------- | ----------------- | --------------------------------------------------- |
|
|
| `table` | `string` | `'yjs_documents'` | Name of the Postgres table used to store documents. |
|
|
| `schema` | `string` | `'public'` | Schema where the table is located. |
|
|
| `roomColumn` | `string` | `'room'` | Column used as the document identifier. |
|
|
| `stateColumn` | `string` | `'state'` | Column used to store the binary Yjs state. |
|
|
| `storeTimeout` | `number` | `1000` | Debounce delay (ms) before persisting changes. |
|
|
|
|
## Further reading
|
|
|
|
- [Realtime Broadcast](https://supabase.com/docs/guides/realtime/broadcast)
|
|
- [Realtime authorization](https://supabase.com/docs/guides/realtime/authorization)
|
|
- [`@supabase-labs/y-supabase`](https://github.com/supabase-community/y-supabase)
|
|
- [Yjs documentation](https://docs.yjs.dev/)
|