Comments
Pin comments on any page of your site, sign in with GitHub, and post threads to the preview's pull request.
Deploys on
.env
# Sign in with GitHub: people who can push to the repository may comment
VITEHUB_GITHUB_CLIENT_ID=Iv23li...
VITEHUB_GITHUB_CLIENT_SECRET=...
VITEHUB_SECRET=...Pick a setup
Section titled "Pick a setup"Start with one plugin and add more later.
| Setup | You add | You get |
|---|---|---|
| Comments alone | comments() in vite.config.ts | Pins, threads, replies, and resolve on every page. Threads in your database, Turso, Cloudflare D1, or a SQLite file, in tables Comments creates. Guests on the dev server. |
| With GitHub sign-in | A GitHub App and three server variables | People who can push to the repository sign in and comment. Pull request comments show their GitHub account. |
| In a ViteHub app | vitehub() with a Database, and server/comments.ts | Any ViteHub Database on every host. Live cursors, Content edits in place, the Console section, MCP tools for Agents, and your own sign-in. |
| On a docs site | vite-hub/nuxt beside vite-hub/docs/nuxt | On by default on every docs page, with threads in the Console. Set docs: { comments: false } to turn it off. |
One plugin turns it on
Add
comments() to vite.config.ts to get the API, the page overlay, and a SQLite file for threads.Sign in with GitHub
People who can push to the repository can comment. The session is a cookie, and the server stores no users.
Public visitors get nothing extra
The overlay loads only for readers that
authorize allows, on a request with ?vitehub or the vitehub-tools cookie.Pins follow the text
A pin finds its element after a resize or layout change. A pin on a Content field survives a redesign.
See who is on the page
With Realtime, people on a page see each other's avatars and cursors, and new comments appear at once.
Edit Content text in place
Mark an element with
contentField(). Edits save a Content draft that you publish in the Console.Decide who can comment
authorize() allows or denies read, write, resolve, and delete per user, and can let guests comment.Comments through Operations
Section titled "Comments through Operations"The same server/comments.ts file also runs the comment operations: numbered threads on your own subjects, for the CLI, MCP, the Console, and your UI. Export the definition as comments or as the default export. Both use the same tables.
Use without ViteHub
Section titled "Use without ViteHub"@vite-hub/comments also works in a Vite app without vite-hub. Install it, add the comments() plugin, and import from @vite-hub/comments:
npm
npm install @vite-hub/comments [email protected] valibotpnpm
pnpm add @vite-hub/comments [email protected] valibotyarn
yarn add @vite-hub/comments [email protected] valibotbun
bun add @vite-hub/comments [email protected] valibotimport vue from '@vitejs/plugin-vue'
import comments from '@vite-hub/comments/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [vue(), comments()],
})import { defineComments } from '@vite-hub/comments'
export const comments = defineComments({
authorize: ({ user, action }) => action === 'read' || user?.github?.write === true,
})Do not add comments() next to vitehub(). Get started walks through this setup.