### Install shadcn/ui with Next.js
Source: https://supabase.com/ui/docs/getting-started/quickstart
Use this command to start a new Next.js project with Supabase UI integration. Ensure you have Node.js and npm/yarn installed.
```bash
npx create-next-app -e with-supabase
```
--------------------------------
### Install All Supabase Skills CLI
Source: https://supabase.com/ui/docs/ai-editors-rules/skills
Installs the full set of Supabase skills for most projects. Run this command in the root of your project.
```bash
npx skills add supabase/agent-skills
```
--------------------------------
### Install Infinite Query Hook
Source: https://supabase.com/ui/docs/infinite-query-hook
Install the infinite query hook using npm, yarn, or pnpm.
```bash
npx shadcn@latest add @supabase/infinite-query-hook
```
--------------------------------
### Install Platform Kit for Next.js
Source: https://supabase.com/ui/docs/platform/platform-kit
Use this command to add the Platform Kit to your Next.js project. Ensure you have npx, npm, yarn, or bun installed.
```bash
npx shadcn@latest add @supabase/platform-kit-nextjs
```
--------------------------------
### Install Supabase Postgres Best Practices Skill CLI
Source: https://supabase.com/ui/docs/ai-editors-rules/skills
Installs the Postgres-specific skill for database work, focusing on performance optimization, query design, and schema best practices. Use this in addition to the full set if you do extensive database work.
```bash
npx skills add supabase/agent-skills --skill supabase-postgres-best-practices
```
--------------------------------
### Install Current User Avatar Next.js
Source: https://supabase.com/ui/docs/nextjs/current-user-avatar
Install the Current User Avatar component for Next.js using npm, yarn, or bun.
```bash
npx shadcn@latest add @supabase/current-user-avatar-nextjs
```
--------------------------------
### Usage Example of CurrentUserAvatar
Source: https://supabase.com/ui/docs/nextjs/current-user-avatar
Demonstrates how to integrate the CurrentUserAvatar component into your Next.js application. This example shows it within a header component.
```typescript
'use client'
import { CurrentUserAvatar } from '@/components/current-user-avatar'
const CurrentUserAvatarDemo = () => {
return (
Lumon Industries
Upload{!!maxFiles && maxFiles > 1 ? ` ${maxFiles}` : ''} file {!maxFiles || maxFiles > 1 ? 's' : ''}
Drag and drop or{' '} inputRef.current?.click()} className="underline cursor-pointer transition hover:text-foreground" > select {maxFiles === 1 ? `file` : 'files'} {' '} to upload
{maxFileSize !== Number.POSITIVE_INFINITY && (Maximum file size: {formatBytes(maxFileSize, 2)}
)}Follow this link to confirm your user:
``` -------------------------------- ### Create Table for Persistence Source: https://supabase.com/ui/docs/nextjs/realtime-monaco SQL statement to create the necessary table in Supabase for persisting Yjs document state. ```sql create table yjs_documents ( room text primary key, state text not null ); ``` -------------------------------- ### Create Supabase Browser Client for Next.js Source: https://supabase.com/ui/docs/nextjs/client Use this function to create a Supabase client for browser-side operations in your Next.js application. Ensure NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY environment variables are set. ```typescript import { createBrowserClient } from '@supabase/ssr' export function createClient() { return createBrowserClient( process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY! ) } ``` -------------------------------- ### Usage of RealtimeAvatarStack Component Source: https://supabase.com/ui/docs/nextjs/realtime-avatar-stack Integrate the RealtimeAvatarStack component into your Next.js application to display online users. Pass a `roomName` prop to specify the Supabase Realtime room. ```typescript import { RealtimeAvatarStack } from '@/components/realtime-avatar-stack' export default function Page() { return (92 Successfully uploaded {files.length} file{files.length > 1 ? 's' : ''} 93
94121 {file.name} 122
123 {file.errors.length > 0 ? ( 124125 {file.errors 126 .map((e) => 127 e.message.startsWith('File is larger than') 128 ? `File is larger than ${formatBytes(maxFileSize, 2)} (Size: ${formatBytes(file.size, 2)})` 129 : e.message 130 ) 131 .join(', ')} 132
133 ) : loading && !isSuccessfullyUploaded ? ( ``` -------------------------------- ### RealtimeMonaco Component Implementation Source: https://supabase.com/ui/docs/nextjs/realtime-monaco The core React component for the Realtime Monaco editor. It uses the `useConnectOnMount` hook to establish connections for persistence and awareness. ```typescript 'use client' import { Editor } from '@monaco-editor/react' import { SupabasePersistenceOptions } from '@supabase-labs/y-supabase' import { Awareness } from 'y-protocols/awareness.js' import { useConnectOnMount } from '../hooks/use-connect-on-mount' type RealtimeMonacoProps = { channel: string language?: string height?: string | number className?: string awareness?: boolean | Awareness persistence?: boolean | SupabasePersistenceOptions theme?: 'light' | 'dark' } const DEFAULT_HEIGHT = 550 const RealtimeMonaco = ({ channel, language = 'javascript', height = DEFAULT_HEIGHT, awareness = true, persistence, theme, ...rest }: RealtimeMonacoProps) => { const { connectOnMount } = useConnectOnMount({ channel, persistence, awareness }) return (