Use the add-velt CLI to scaffold Velt collaboration features into your Next.js app with a single command.
Add Velt real-time collaboration to an existing Next.js project from your terminal. The CLI installs dependencies, generates components, and auto-wires VeltProvider into your app layout. No manual configuration required.
Detects your project: finds next.config.js/next.config.ts, determines App Router vs Pages Router, and identifies your package manager (npm, yarn, or pnpm with workspace support)
Installs dependencies: adds @veltdev/react and @veltdev/types, plus feature-specific packages (e.g., yjs for CRDT)
Generates components: creates files under components/velt/ for collaboration, document initialization, and user authentication
Copies assets: adds icon SVGs to public/icons/ when features like notifications are selected
After the CLI completes, you need to manually wrap your page content with VeltProvider. The CLI skips auto-wiring the layout if it detects a metadata export (server component). See the Troubleshooting section for the required code.
After running the CLI, wrap your page content with VeltProvider in the page where collaboration happens (NOT in layout.tsx):
// app/dashboard/[docId]/page.tsx (or your collaboration page)"use client";import { VeltProvider } from '@veltdev/react';import { useVeltAuthProvider } from '@/components/velt/VeltInitializeUser';import { VeltCollaboration } from '@/components/velt/VeltCollaboration';export default function DocumentPage() { const { authProvider } = useVeltAuthProvider(); return ( <VeltProvider apiKey={process.env.NEXT_PUBLIC_VELT_API_KEY!} authProvider={authProvider}> <VeltCollaboration documentId={docId} /> {/* Your page content */} </VeltProvider> );}
Do NOT place VeltProvider in app/layout.tsx. If your layout exports metadata (a server-only feature), adding VeltProvider there requires "use client" which conflicts with the metadata export. Place VeltProvider in the specific page where collaboration features are needed.