Skip to content

Embed your forum in your product

Your community does not have to live only at your-forum.infoemu.com. You can render live threads and comment boxes inside your own product — a docs page that shows the discussion for that page, a changelog with comments, a dashboard widget listing the latest questions. The embeds talk to the same forum API your community already runs, so posts made in your app show up in the forum and the other way around.

Plan: the forum API is included on Community Pro and above. Public (signed-out) embeds also need two settings, covered below.

Component Shows Typical use
<ThreadList> the topics in one forum, with paging “Latest questions” widget, a support page
<Comments> one topic’s posts as a threaded tree, plus a reply box comments under a docs page, blog post or release note

Both come from the @infoemu/react package. It has no runtime dependencies apart from React 18 or 19 itself, and ships one small stylesheet that you can theme with CSS variables.

The package is not on npm yet. Until it is, ask us for the tarball or build it from source (pnpm install && pnpm build && pnpm pack) and install the .tgz with pnpm add ./infoemu-react-0.1.0.tgz.

There are three ways an embed can authenticate. Pick one before you write any code:

  1. Signed-out visitors (public read). Best for public pages: anyone can read the thread, nobody can post from the embed. Needs the two settings in step 2. Hide the reply box.
  2. Your signed-in user, by token. Your app signs the user in to the forum (client.signIn(...) with their forum credentials) and passes the returned token to the embed. They read and post as themselves.
  3. Same-origin session. If the embed runs on a page served from the forum’s own domain (or behind the same single sign-on session), the session cookie is enough — no token needed.

Never put a moderator’s or admin’s token into a public page: anyone visiting the page could post as that account.

2. Turn on public read and allow your site (public embeds only)

Section titled “2. Turn on public read and allow your site (public embeds only)”

In the console, open your community, go to Settings, and set:

Setting Value What it does
FORUM_API_PUBLIC_READ true Serves the read endpoints to signed-out visitors, with exactly the same visibility as a guest browsing the forum. Private forums stay hidden; writes still need a sign-in.
API_CORS_ORIGINS https://docs.example.com,https://app.example.com The exact origins (scheme + host, no path) allowed to call the API from a browser. Use * only for read-only, signed-out embeds.

Save and restart the community when the console asks. Both settings are off by default.

import { Comments, createClient, InfoEmuProvider, ThreadList } from "@infoemu/react";
import "@infoemu/react/styles.css";
// Public page: signed-out, read-only.
const client = createClient({
baseUrl: "https://your-forum.infoemu.com",
credentials: "omit",
});
export function Discussion() {
return (
<InfoEmuProvider client={client}>
<ThreadList forumId={2} onSelectTopic={(t) => console.log("open", t.id)} />
<Comments topicId={17} showReplyBox={false} />
</InfoEmuProvider>
);
}

For signed-in users, create the client with their token instead:

const result = await createClient({ baseUrl }).signIn({ login, password });
// result.data.authentication_token — accounts with two-factor sign-in
// get status "needs_mfa" instead and must finish signing in on the forum.
const client = createClient({ baseUrl, token: result.data.authentication_token });

Tokens expire after an hour by default; sign in again when a request returns 401.

<ThreadList> — forumId, topicType, importantOnly, pageSize, onSelectTopic(topic), className.

<Comments> — topicId (required), view ("threaded", the default, or "classic"), pageSize, maxDepth, showReplyBox (default true), onPosted(post), className.

Post bodies are rendered from the forum’s own sanitized HTML, so formatting, code blocks and mentions look the same as in the forum.

Import the stylesheet once and override its variables on the embed or on any parent element:

.docs-discussion {
--ie-accent: #2563eb; /* buttons, links, focus ring */
--ie-radius: 4px;
--ie-font: "Inter", system-ui, sans-serif;
}

The other variables are --ie-text, --ie-muted, --ie-bg, --ie-surface, --ie-border and --ie-danger.

A common pattern is one forum topic per docs page or blog post. Create the topic once, either in the forum or through the API (POST /api/forum/v1/topics), keep its id next to the page (for example in the page’s front matter), and render <Comments topicId={...}> with it. Put these topics in a dedicated forum, such as “Docs feedback”, so they don’t crowd your main categories.

The components are a thin layer over the forum API, so any stack can do the same with plain HTTP. Every endpoint is under https://your-forum.infoemu.com/api/forum/v1 and speaks JSON:

Purpose Request
list topics in a forum GET /topics?forum_id=2&page=1&page_size=20
one topic GET /topics/{id}
a topic’s posts as a tree GET /topics/{id}/posts?view=threaded
reply POST /topics/{id}/posts with {"content": "..."}

Send Authentication-Token: <token> for signed-in requests. Paging totals are in the X-Pagination response header. See APIs, tokens & MCP for the whole API.

  • The browser console shows a CORS error. The page’s origin is missing from API_CORS_ORIGINS, or it is listed with a path or trailing slash. List the bare origin, like https://docs.example.com.
  • 401 for signed-out visitors. FORUM_API_PUBLIC_READ is not true, or the community wasn’t restarted after you changed it.
  • A topic you can see in the forum is missing from the embed. Signed-out embeds show what a guest sees. Check the forum’s guest permissions under Members, groups & permissions.
  • Wildcard origin and a token at the same time fails. Browsers refuse credentialed requests to *. List exact origins when you use tokens.
  • Embeds don’t update live; re-mount <Comments> or refetch to show new posts.
  • Single sign-on (Keycloak) browser sign-in isn’t built into the components yet; use a token or a same-origin session.
  • Signed-out embeds are read-only by design.