GitHub Discussions adapter

Store fuma-comment comments in GitHub Discussions, via @fuma-comment/github-discussions. GitHub is the store, the moderation, and the identity, so there's no database and no separate auth. This page is both the docs and a live demo running against Quixomatic/fuma-comment in Demo Category.

Try it

Sign in with your GitHub account to post; replies and 👍 / 👎 reactions work too, and whatever you post shows up on the GitHub discussion. See the discussions on GitHub →

Leave comment

Configure

createGithubDiscussionsAdapter returns both storage and auth, so spread it into NextComment. It's auth-agnostic: you only supply getToken (how to read the reader's GitHub token). This example ships a reference OAuth flow in lib/github-oauth.ts that stores the token in an httpOnly, encrypted cookie.

import { NextComment } from "@fuma-comment/server/next";
import { createGithubDiscussionsAdapter } from "@fuma-comment/github-discussions";

const github = createGithubDiscussionsAdapter({
  repo: "owner/name",
  repoId: process.env.GITHUB_REPO_ID!,       // R_...
  categoryId: process.env.GITHUB_CATEGORY_ID!, // DIC_...
  category: "Comments",
  ownerLogins: ["owner"],
  readToken: process.env.GITHUB_READ_TOKEN,
  getToken: (request) => tokenFromYourCookie(request),
});

export const { GET, POST, PATCH, DELETE } = NextComment({
  role: "database",
  mention: { enabled: true },
  ...github,
});

Options

OptionRequiredDescription
repoyes"owner/name" of the public repo storing the discussions.
repoIdyesRepository node id (R_...), to open new discussions.
categoryIdyesDiscussions category node id (DIC_...) for new threads.
getTokenyesResolve the reader's GitHub token from the request (or null when signed out).
categorynoCategory name; scopes the search that finds a page's discussion.
ownerLoginsnoGitHub logins allowed to moderate (with role: "database").
readTokennoServer PAT for anonymous reads + opening threads (public_repo).
pageToTitlenoMap a page to the Discussion title (default: identity).
pageToUrlnoMap a page to the URL placed in a new discussion's seed body.

Notes