Add Velt real-time collaboration to an existing Next.js project from your terminal. The CLI installs dependencies, generates components, and auto-wiresDocumentation Index
Fetch the complete documentation index at: https://docs.velt.dev/llms.txt
Use this file to discover all available pages before exploring further.
VeltProvider into your app layout. No manual configuration required.
GitHub Repository
velt-js/add-velt-next-js
When to Use the CLI
- You want to add Velt to a Next.js project quickly from the command line
- You prefer a non-interactive, flag-driven workflow
- You want to scaffold specific features (comments, notifications, CRDT) in one step
- You are setting up Velt without an AI coding assistant
If you are using an AI coding agent like Claude Code or Cursor, see the MCP Installer for an AI-assisted setup experience.
Prerequisites
- Node.js 18+
- Next.js 13.4.0+ (App Router or Pages Router)
- React 18.2.0+
- Package manager: npm, yarn, or pnpm
- A Velt API key
Quickstart
Run the CLI in your Next.js project directory:@veltdev/react, @veltdev/types) and generates core components. To include specific features, add flags:
.env.local:
components/velt/VeltInitializeDocument.tsx: replace the placeholder document ID with your own (e.g., from a route parameter)components/velt/VeltInitializeUser.tsx: replace the placeholder user object with your real user context
Configuration
API Key
The CLI wiresVeltProvider to read your API key from the NEXT_PUBLIC_VELT_API_KEY environment variable. Add it to .env.local:
Document ID
Updatecomponents/velt/VeltInitializeDocument.tsx with your document ID source:
User Authentication
Updatecomponents/velt/VeltInitializeUser.tsx with your user retrieval logic:
Options
Feature Flags
| Flag | Description |
|---|---|
--comments | Add inline comments (VeltComments, VeltCommentsSidebar, VeltCursor) |
--notifications | Add notifications (VeltNotificationsTool, VeltCursor) |
--presence | Add presence indicators (VeltPresence) |
--cursors | Add live cursors (VeltCursor) |
The CLI supports core scaffolding features. For additional features like Recorder, Single Editor Mode, Self-Hosting Data, Activity Logs, and Huddle, use the MCP Installer with an AI coding agent.
CRDT Type Flags (choose one)
| Flag | Description |
|---|---|
--reactflow-crdt | Canvas collaboration with ReactFlow |
--tiptap-crdt | Rich text editor collaboration with Tiptap |
--codemirror-crdt | Code editor collaboration with CodeMirror |
Combined Flag
| Flag | Description |
|---|---|
--all | Enable comments + notifications + CRDT (requires a CRDT type flag) |
Installation Flags
| Flag | Description |
|---|---|
--force, -f | Force overwrite existing files |
--legacy-peer-deps | Use legacy peer deps (npm only) |
--help, -h | Show help message |
What the CLI Does
The CLI performs these steps automatically:- 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/reactand@veltdev/types, plus feature-specific packages (e.g.,yjsfor 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
VeltProvider. The CLI skips auto-wiring the layout if it detects a metadata export (server component). See the Troubleshooting section for the required code.
Generated Files
Core (always created)
With features enabled
When you use--comments, --notifications, or CRDT flags, the CLI also generates:
VeltTools into your page:
Examples
Troubleshooting
Dependency conflicts
If installation fails due to peer dependency issues:--force and --legacy-peer-deps as fallbacks.
Existing files
Use--force to overwrite previously generated files:
Multiple CRDT types
Only one CRDT type can be selected at a time:--all without a CRDT type
The --all flag requires a CRDT type:
Manual VeltProvider setup
After running the CLI, wrap your page content withVeltProvider in the page where collaboration happens (NOT in layout.tsx):
Next Steps
- Quickstart: Manual step-by-step Velt setup (without the CLI)
- Agent Skills: Teach your AI coding agent correct Velt patterns
- MCP Installer: AI-assisted Velt installation through MCP
- Comments Overview: Learn about commenting features
- CRDT Setup: Set up collaborative editing
- Key Concepts: Understand documents, locations, users, and access control

