WASM-based embedded comment system for Discourse forums
npm install discourse-commentsWASM-powered embedded comment system for Discourse forums.
- Framework-agnostic web component
- WASM-based Discourse API client
- OAuth authentication via Discourse User API Keys
- Shadow DOM isolation
- TypeScript support
``bash`
git clone https://github.com/ducks/discourse-comments.git
cd discourse-comments
npm install
npm run build
In your Discourse admin panel (/admin/site_settings), configure these settings:
- cors_origins: Add the domain where you'll host the component
(e.g., https://your-blog.com)user_api_key_allowed_auth_redirects
- : Add the full URL pattern for OAuthhttps://your-blog.com/*
redirects (e.g., )
Create a topic in your Discourse forum that will hold the comments. Note the
topic ID from the URL (e.g., /t/my-post-comments/123 has topic ID 123).
Copy the dist/ and wasm/ folders to your site, then add:
`html
topic-id="123">
`
`bash`
npm install
npm run build
Open demo.html in a browser to see the component in action.
Discourse Version: For authenticated commenting (OAuth login), your Discourse
instance must be running a version from December 11, 2025 or later. This is
when RSA-OAEP padding support was added for User API Key encryption
(PR #36592).
Anonymous comment reading works on any Discourse version.
CORS Configuration: Your Discourse instance needs to allow requests from
wherever you host this component. Set cors_origins in site settings.
OAuth Redirect: For login to work, add your demo URL to the allowed
user_api_key_allowed_auth_redirects site setting.
- src/discourse-comments.ts` - Web component implementation
- WASM client from discourse-api-rs