GitHub 37
Skip to content
ViteHub is still experimental. Expect bugs and breaking changes.

Comments

Pin comments on any page of your site, sign in with GitHub, and post threads to the preview's pull request.

.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=...
.env

Start with one plugin and add more later.

SetupYou addYou get
Comments alonecomments() in vite.config.tsPins, 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-inA GitHub App and three server variablesPeople who can push to the repository sign in and comment. Pull request comments show their GitHub account.
In a ViteHub appvitehub() with a Database, and server/comments.tsAny 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 sitevite-hub/nuxt beside vite-hub/docs/nuxtOn 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.

Notify the people you mention

people fills the @ list. onComment runs after each comment, for example to send an Email.

Triage in the Console

The Comments section lists each thread with its page and status, and links to the pin.

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.

@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] valibot
pnpm
pnpm add @vite-hub/comments [email protected] valibot
yarn
yarn add @vite-hub/comments [email protected] valibot
bun
bun add @vite-hub/comments [email protected] valibot
import vue from '@vitejs/plugin-vue'
import comments from '@vite-hub/comments/vite'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [vue(), comments()],
})
vite.config.ts
import { defineComments } from '@vite-hub/comments'

export const comments = defineComments({
  authorize: ({ user, action }) => action === 'read' || user?.github?.write === true,
})
alone/server/comments.ts

Do not add comments() next to vitehub(). Get started walks through this setup.