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 →
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
| Option | Required | Description |
|---|---|---|
repo | yes | "owner/name" of the public repo storing the discussions. |
repoId | yes | Repository node id (R_...), to open new discussions. |
categoryId | yes | Discussions category node id (DIC_...) for new threads. |
getToken | yes | Resolve the reader's GitHub token from the request (or null when signed out). |
category | no | Category name; scopes the search that finds a page's discussion. |
ownerLogins | no | GitHub logins allowed to moderate (with role: "database"). |
readToken | no | Server PAT for anonymous reads + opening threads (public_repo). |
pageToTitle | no | Map a page to the Discussion title (default: identity). |
pageToUrl | no | Map a page to the URL placed in a new discussion's seed body. |
Notes
- One level of replies, matching GitHub Discussions.
- @mention autocomplete uses repository.mentionableUsers; enable it with mention: { enabled: true }.
- readToken needs Discussions read + write (a classic public_repo PAT). Without it, signed-out visitors see no comments and own-comment deletes are blocked.
- Rich content round-trips through Markdown. What the editor can't represent degrades: headings, lists and quotes become paragraphs, and images without dimensions become links.
- A page maps to a Discussion by title, resolved through GitHub's search index. Set pageToTitle to keep those titles unique.