Add Comments to Your Astro Site in Minutes
Comments, Reactions, and Ratings With Zero Added JavaScript in Your Bundle
Astro ships as little JavaScript as possible, and so does this. Create one small component, add it to your blog post page, and readers get a full comment section with replies, reactions, and moderation.
Steps to Add Comments to Astro
Sign up at the Hyvor Talk Console and add your website with your site's domain. You'll need the website ID from Settings → Website.
Create
src/components/Comments.astro. ReplaceYOUR_WEBSITE_IDwith your website ID.--- interface Props { pageId: string; } const { pageId } = Astro.props; --- <script is:inline async src="https://talk.hyvor.com/embed/embed.js" type="module"></script> <hyvor-talk-comments website-id="YOUR_WEBSITE_ID" page-id={pageId}></hyvor-talk-comments>Add it to your blog post page, after the content. Here's an example with a content collection named
blog, insrc/pages/blog/[slug].astro:--- import { getCollection, render } from 'astro:content'; import Comments from '../../components/Comments.astro'; export async function getStaticPaths() { const posts = await getCollection('blog'); return posts.map((post) => ({ params: { slug: post.id }, props: { post } })); } const { post } = Astro.props; const { Content } = await render(post); --- <article> <h1>{post.data.title}</h1> <Content /> </article> <Comments pageId={post.id} />Run
npm run dev, open a post, and you'll see the comments under it. Then build and deploy as usual.
Using React, Vue, or Svelte in Astro?
If your Astro site already uses a UI framework, you can use our React, Vue, or Svelte library as an island instead. For example, with React:
---
import { Comments } from '@hyvor/hyvor-talk-react';
---
<Comments client:only="react" website-id={YOUR_WEBSITE_ID} page-id={post.id} />This is handy when you want to listen to comment events in your own component code.
That's it. Your Astro site now has comments. Change colors and texts in the Console, or see styles for custom CSS.
Frequently asked questions
No. Hyvor Talk is a web component, so it works in a plain .astro file with no React, Vue, or Svelte installed. Nothing is added to your bundle, and the script loads from Hyvor Talk's servers.
By default, Astro processes and bundles <script> tags. is:inline tells Astro to leave this one as it is, so the browser loads the embed script straight from Hyvor Talk.
You don't need one. The small component above does the same job as a comments plugin, and you keep full control of where it renders.
The entry ID from your content collection is a good choice. It stays the same even if you change your URL structure later. See page-id for details.
Storing comments, logins, replies, notifications, spam filtering, and moderation. Your Astro site stays static, and the comments load in the browser.
Yes, with single sign-on. If your Astro site has accounts, pass the user data to the component and they skip the Hyvor login. SSO is on the Business plan.
Yes. The trial runs for 14 days and needs no credit card. See pricing.