Skip to content
VercelLogotypeVercelLogotype
LoginSign Up

Velt Next.js Starter Kit

Collaborative docs app: real-time editing, comments, presence, live cursors, and per-document sharing. Built with Next.js and Velt.

DeployView Demo

A full collaborative-documents app built with Next.js (App Router) and Velt — like a minimal Google Docs. Sign in, see your documents, create new ones, share them with teammates (viewer / editor), and edit together in real time.

It demonstrates the core Velt features inside a realistic, multi-user app with working access control:

  • Real-time editing (CRDT) — a TipTap editor synced with Yjs
  • Comments — inline comments on selected text + a comments sidebar
  • Presence & live cursors — see who's online and where their cursor is
  • Notifications — in-app panel for mentions, replies and shares
  • Sharing & permissions — restricted documents with per-user viewer/editor roles, enforced by Velt

Tech stack

  • Next.js 16 (App Router) · React 19 · TypeScript
  • Velt SDK (@veltdev/react) + TipTap CRDT & Comments packages
  • Tailwind CSS v4

Deploy to Vercel

Click the Deploy with Vercel button above. The clone flow will prompt for the two required Velt environment variables (NEXT_PUBLIC_VELT_API_KEY, VELT_AUTH_TOKEN) and deploy the tiptap/ directory.

Then add a storage backend so the document directory persists (Vercel's runtime filesystem is read-only, so the local JSON store can't be used in production):

  1. In your Vercel project: Storage → Create Database → Upstash for Redis and Connect to Project. Vercel injects KV_REST_API_URL + KV_REST_API_TOKEN automatically (the variables lib/documentStore.ts reads).
  2. Redeploy.

See The document directory: local dev vs. hosting for details.

Getting started

1. Get your Velt credentials

Create an app at console.velt.dev and copy your API key and Auth Token.

2. Configure environment variables

cp .env.example .env
# .env
NEXT_PUBLIC_VELT_API_KEY=your_velt_api_key_here # public, used in the browser
VELT_AUTH_TOKEN=your_velt_auth_token_here # secret, server-only (token + REST calls)

3. Install & run

pnpm install # or npm install / yarn
pnpm dev

Open http://localhost:3000.

4. Try collaboration with two users

  1. In your main browser, pick a demo user on the sign-in page, then create a document.
  2. Open a second browser (or an incognito window) and sign in as a different demo user.
  3. That user's dashboard is empty — the document is restricted and not shared yet.
  4. Back in the first browser, click Share and invite the second user as Editor.
  5. Reload the second browser — the document now appears and opens. Type together, add comments, and watch presence avatars + live cursors update in real time.
  6. Change the second user to Viewer and reload — their editor becomes read-only. Revoke access and reload — they're locked out.

How it works

Authentication (demo)

app/userAuth/AppUserContext.tsx stores the demo user you pick on /signin in localStorage. The fixed demo users live in lib/demoUsers.ts.

In your real app: delete the demo pieces and pass your authenticated user (from NextAuth, Clerk, Auth0, …) to Velt. The only integration point is components/velt/VeltInitializeUser.tsx.

Identifying the user to Velt

components/velt/VeltInitializeUser.tsx builds the Velt authProvider. Its generateToken callback calls POST /api/velt/token, which mints a JWT via the Velt REST API encoding the user's access to the organization and the document they're opening (with their viewer / editor role).

Documents, sharing & permissions

Velt is the source of truth for collaboration data and permission enforcement, but it has no "list every document a user can access" query — so the dashboard keeps a small directory of its own.

  • lib/veltRest.ts — server-only wrapper around the Velt REST API (create / rename / delete documents, set access type, grant / revoke permissions).
  • lib/documentStore.ts — the per-organization document directory used to render each user's dashboard. This is the only place that touches storage.
ActionRouteVelt REST calls
CreatePOST /api/documentsdocuments/add → documents/access/update (restricted) → auth/permissions/add (owner = editor)
ListGET /api/documents— (reads the directory)
Rename / DeletePATCH / DELETE /api/documents/[id]documents/update / documents/delete
Share / RevokePOST / DELETE /api/documents/[id]/shareauth/permissions/add / auth/permissions/remove

A newly created document is set to restricted, so only explicitly invited users can access it. AccessGate (app/documents/[id]/AccessGate.tsx) mirrors this on the client: no access → locked screen, viewer → read-only editor.

Velt also ships a drop-in <VeltUserInviteTool /> share UI. This kit uses a custom ShareMenu so sharing is wired to the backend and the dashboard directory, but you can swap in the native tool if you prefer.

The document directory: local dev vs. hosting

lib/documentStore.ts picks its backend automatically:

  • Local development — no config needed. It writes one JSON file per org under data/ (gitignored).
  • Hosted / serverless (e.g. Vercel) — the runtime filesystem is read-only, so the JSON-file path can't write (you'll see ENOENT … mkdir '/var/task/.../data'). Provision a Vercel KV (Upstash Redis) store and the directory is kept in Redis instead.

Deploying to Vercel:

  1. In your Vercel project, open Storage → Create Database → KV (Upstash Redis) and connect it to the project. Vercel injects KV_REST_API_URL and KV_REST_API_TOKEN automatically.
  2. Add NEXT_PUBLIC_VELT_API_KEY and VELT_AUTH_TOKEN as environment variables.
  3. Redeploy. The store now uses Redis (durable across instances).

lib/documentStore.ts is the only place that touches storage, so swapping Redis for Postgres/SQLite/etc. is a single-file change.


Project structure

app/
signin/ demo-user picker
dashboard/ list / create / rename / delete documents
documents/[id]/ collaborative editor + ShareMenu + AccessGate
document/ document metadata context (role, members)
userAuth/ demo auth (swap for your real auth)
api/
velt/token/ mint Velt JWTs (encodes per-document role)
documents/ create / list / rename / delete / share
components/
document/ TipTap editor (CRDT + comments wiring)
velt/ Velt provider, document setup, tools, collaboration
header/ sidebar/ ui/ app chrome
lib/
demoUsers.ts fixed demo users
veltRest.ts server-only Velt REST wrapper
documentStore.ts document directory (swap for a DB in production)

Learn more

  • Velt docs · Velt REST API
  • Next.js docs · TipTap docs
GitHubSource
Use Cases
Realtime Apps
Starter
SaaS
Stack
Next.js
Tailwind
Database
Upstash
Redis

Related Templates

Next.js Boilerplate

Get started with Next.js and React in seconds.
Next.js Boilerplate thumbnail

Image Gallery Starter

An image gallery built on Next.js and Vercel Blob.
Image Gallery Starter thumbnail

Chatbot

A full-featured, hackable Next.js AI chatbot built by Vercel
Chatbot thumbnail

Get Started

  • Templates
  • Supported frameworks
  • Marketplace
  • Domains

Build

  • Next.js on Vercel
  • Turborepo
  • v0

Scale

  • Content delivery network
  • Fluid compute
  • CI/CD
  • Observability
  • AI GatewayNew
  • Vercel AgentNew

Secure

  • Platform security
  • Web Application Firewall
  • Bot management
  • BotID
  • SandboxNew

Resources

  • Pricing
  • Customers
  • Enterprise
  • Articles
  • Startups
  • Solution partners

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Community

Frameworks

  • Next.js
  • Nuxt
  • Svelte
  • Nitro
  • Turbo

SDKs

  • AI SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDK
  • Streamdown AINew

Use Cases

  • Composable commerce
  • Multi-tenant platforms
  • Web apps
  • Marketing sites
  • Platform engineers
  • Design engineers

Company

  • About
  • Careers
  • Help
  • Press
  • Legal
  • Privacy Policy
  • Security

Community

  • Open source program
  • Events
  • Shipped on Vercel
  • GitHub
  • LinkedIn
  • X
  • YouTube
  • VercelVercel
    • AI Cloud
      • AI Gateway

        One endpoint, all your models

      • Sandbox

        Isolated, safe code execution

      • Vercel Agent

        An agent that knows your stack

      • AI SDK

        The AI Toolkit for TypeScript

      • v0

        Build applications with AI

    • Core Platform
      • CI/CD

        Helping teams ship 6× faster

      • Content Delivery

        Fast, scalable, and reliable

      • Fluid Compute

        Servers, in serverless form

      • Workflow

        Long-running workflows at scale

      • Observability

        Trace every step

    • Security
      • Bot Management

        Scalable bot protection

      • BotID

        Invisible CAPTCHA

      • Platform Security

        DDoS Protection, Firewall

      • Web Application Firewall

        Granular, custom protection

    • Company
      • Customers

        Trusted by the best teams

      • Blog

        The latest posts and changes

      • Changelog

        See what shipped

      • Press

        Read the latest news

      • Events

        Join us at an event

    • Learn
      • Docs

        Vercel documentation

      • Academy

        Linear courses to level up

      • Knowledge Base

        Find help quickly

      • Community

        Join the conversation

    • Open Source
      • Next.js

        The native Next.js platform

      • Nuxt

        The progressive web framework

      • Svelte

        The web’s efficient UI framework

      • Turborepo

        Speed with Enterprise scale

    • Use Cases
      • AI Apps

        Deploy at the speed of AI

      • Composable Commerce

        Power storefronts that convert

      • Marketing Sites

        Launch campaigns fast

      • Multi-tenant Platforms

        Scale apps with one codebase

      • Web Apps

        Ship features, not infrastructure

    • Tools
      • Marketplace

        Extend and automate workflows

      • Templates

        Jumpstart app development

      • Partner Finder

        Get help from solution partners

    • Users
      • Platform Engineers

        Automate away repetition

      • Design Engineers

        Deploy for every idea

  • Enterprise
  • Pricing
Log InContact
Sign Up
Sign Up
ContactDashboard
DeployView Demo

Loading status…

Select a display theme:
AI Gateway

One endpoint, all your models

Sandbox

Isolated, safe code execution

Vercel Agent

An agent that knows your stack

AI SDK

The AI Toolkit for TypeScript

v0

Build applications with AI

CI/CD

Helping teams ship 6× faster

Content Delivery

Fast, scalable, and reliable

Fluid Compute

Servers, in serverless form

Workflow

Long-running workflows at scale

Observability

Trace every step

Bot Management

Scalable bot protection

BotID

Invisible CAPTCHA

Platform Security

DDoS Protection, Firewall

Web Application Firewall

Granular, custom protection

Customers

Trusted by the best teams

Blog

The latest posts and changes

Changelog

See what shipped

Press

Read the latest news

Events

Join us at an event

Docs

Vercel documentation

Academy

Linear courses to level up

Knowledge Base

Find help quickly

Community

Join the conversation

Next.js

The native Next.js platform

Nuxt

The progressive web framework

Svelte

The web’s efficient UI framework

Turborepo

Speed with Enterprise scale

AI Apps

Deploy at the speed of AI

Composable Commerce

Power storefronts that convert

Marketing Sites

Launch campaigns fast

Multi-tenant Platforms

Scale apps with one codebase

Web Apps

Ship features, not infrastructure

Marketplace

Extend and automate workflows

Templates

Jumpstart app development

Partner Finder

Get help from solution partners

Platform Engineers

Automate away repetition

Design Engineers

Deploy for every idea