Follows
Let VitNode members follow a forum topic or blog article and hear about every new comment, with follow true, rootFollowers and ContentFollowButton.
A follow lets a member hear about every new comment and reply on a forum topic or blog article, not only the ones that answer them. Members click Follow, pick how to hear about it in the panel beside it, see who else follows, and click Following to stop. This page turns follows on for Forum topics and shows the same setup on Blog articles.
Follows ride on content notifications: the follow decides who hears about a comment, and the threadReply rule decides what they read and where the link goes.
Before you begin
You need:
- A working forum, from Run a Community Forum, with one forum.
- Two member accounts, for example Alex and Sam. Nobody is notified about their own comment.
- A published topic both members can read. Post it as a third account, such as the administrator, so neither member is its author and the follow is the only reason Alex hears about it.
The Forum plugin in the VitNode repository already contains the edits below. The steps show where each one lives, so you can make the same changes in your own plugin.
Turn on following for topics
Edit plugins/forum/src/content/topic.ts and add follow: true to the topic type. This is an excerpt:
export const topicContentType = defineContentType({
id: "forum.topic",
// ...
reactions: true,
follow: true,
// ...
});follow needs publicApi, because members can only follow what they can read. It adds three routes to the topic's public module: GET, PUT and DELETE /api/@vitnode/forum/content/topics/{id}/follow. Types without follow do not get them, and a fetcher call to them does not compile.
Notify followers about new comments
Edit the existing forum.comment_reply rule in plugins/forum/src/api/lib/notifications.ts. Add rootFollowers and the followed text:
replies: {
id: "forum.comment_reply",
preset: "threadReply",
recipients: {
authorField: "author",
rootAuthorField: "author",
rootFollowers: true,
},
messages: {
label: "@vitnode/forum.notifications.comment_reply.label",
description: "@vitnode/forum.notifications.comment_reply.description",
comment: "@vitnode/forum.notifications.comment_reply.comment",
reply: "@vitnode/forum.notifications.comment_reply.reply",
followed: "@vitnode/forum.notifications.comment_reply.followed",
},
target: ({ content }) => commentPermalink(content.slug),
email: true,
},The rule is already registered in src/config.api.ts with contentNotifications: [commentNotifications, topicNotifications], so nothing else changes there. email: true lets members pick an email mode for their follows; without it, follows deliver in the app only.
Add the text to plugins/forum/src/locales/api/en.json, next to the other comment_reply keys:
"followed": "{actor} commented on \"{title}\", a topic you follow"{actor} is the comment's author and {title} the topic title, translated into each recipient's language.
Render the Follow control
Add ContentFollowButton to the topic header in plugins/forum/src/pages/topic-page.tsx. Each handler calls the typed fetcher with the topic's numeric id:
import { fetcher } from "@vitnode/core/tanstack/fetcher";
import { ContentFollowButton } from "@vitnode/core/tanstack/follow";
import { topicContentType } from "@/content/topic";
import { manifest } from "@/manifest.gen";
const TopicFollowButton = ({ topicId }: { topicId: number }) => (
<ContentFollowButton
contentTypeId={topicContentType.id}
followers={async ({ cursor }) =>
await fetcher({
plugin: manifest.id,
module: "content/topics",
method: "get",
path: "/{id}/followers",
args: { params: { id: topicId }, query: { cursor } },
})
}
id={topicId}
read={async () =>
await fetcher({
plugin: manifest.id,
module: "content/topics",
method: "get",
path: "/{id}/follow",
args: { params: { id: topicId } },
})
}
save={async body =>
await fetcher({
plugin: manifest.id,
module: "content/topics",
method: "put",
path: "/{id}/follow",
args: { params: { id: topicId }, body },
})
}
unfollow={async () =>
await fetcher({
plugin: manifest.id,
module: "content/topics",
method: "delete",
path: "/{id}/follow",
args: { params: { id: topicId } },
})
}
/>
);Render <TopicFollowButton topicId={topic.id} /> in the header's action bar. Members get three joined buttons: Follow, the follower count, and an arrow that opens the delivery panel. Guests see a Follow link to the sign-in page and never request follow state. Use the record id, not the slug: a slug change keeps the follow.
Build and migrate
Follows live in core tables, so the core migration adds them once. From the workspace root:
bun run build:plugins
bun run db:migrateThe migrations add core_content_follows, with an anonymous column for hidden follows, and a followPreferences column on the notification state. Existing accounts keep working with the defaults: auto-follow off, in-app on, no email.
Check the result
- Sign in as Alex and open the topic. Click Follow. The button changes to Following and the count beside it goes up by one.
- Open the panel with the arrow. A notification for every new comment is checked under In the app, from Alex's account defaults.

With an email adapter configured, the panel also lists By email: No emails, an email for every new comment, a daily email or a weekly email. Without one, it shows no email rows at all. Changes apply when Alex clicks Save, or Follow before following. When in-app and email are both off, the panel says Alex won't be notified.
- In another browser, sign in as Sam and post a comment on the topic.
- Back as Alex, open the bell. "Sam commented on …, a topic you follow" is there. Click it: the comment permalink opens the topic at Sam's comment.

- Open the panel again, check Follow anonymously and click Save. A member who turned on Browse anonymously finds it already checked on new follows. Click the follower count: the followers list shows Alex marked Anonymous, and Sam does not see Alex in it. Anonymous followers still count.
- Click Following to unfollow. The toast offers Undo, which brings back the delivery you had. Leave it, then post another comment as Sam: Alex gets no notification for it. Clicking Follow later starts the follow again with the account defaults.
Choose account defaults
Members set their defaults under Following on /settings/notifications:
- Follow what I reply to follows the topic or article when they comment or reply. A submitted comment waiting for approval counts too. It never overrides an earlier unfollow.
- Notify me in the app and Email new follows are what a new follow starts with.

Changing a default affects new follows only; each existing follow keeps its own choice. The Email switch above it also mutes follow email, and turning email back on restores every follow's saved mode. See Preferences for the details.
Blog articles
Blog articles work the same way. The differences:
follow: truegoes onblog.postinplugins/blog/src/content/post.ts.- The
blog.comment_replyrule setsrecipients: { authorField: "author", rootFollowers: true }. An article lists several authors, so only followers and the replied-to comment's author are notified. - The
fetchercalls usemodule: "content/blog", so the routes are/api/@vitnode/blog/content/blog/{id}/follow. targetstays the existing/blog/comments/{slug}permalink, which opens the comment in the article's language. Localized pages of one article share one follow.
What followers hear about
Followers hear about a comment or reply when it becomes public for the first time, including when a moderator approves it. Drafts, rejected comments, edits, hiding, unhiding and republishing notify nobody. A member who is also the parent comment's or topic's author gets one notification, worded as a reply or comment. Only follows started before the comment went public count, so following later shows future comments only. The full rules are in Follows API.
Related
- Follows API: the routes, the rule options and the React exports.
- Notifications: direct reply and comment notifications.
- Preferences: how members' channel choices combine.