Add emoji reactions to an Astro site
Astro sites can show live emoji reactions with static output and no adapter: the loader goes in BaseLayout.astro with is:inline, a floating bar goes in [slug].astro, and each post on your blog index gets an inline bar keyed to its slug. The bar is a custom element, so there's no framework integration to install.
Before you start
You need a Tapbar: the reactions, the look, and a publishable key (pk_live_…). Sign up, create a Tapbar with your site as an allowed site (add http://localhost:* too, to try it on a dev server), and open its Embed panel — the loader tag there already carries your key. Your AI agent can do this part for you; see the last section.
Add the loader once
The loader goes in the shared <head> (src/components/BaseHead.astro in the blog starter, or your layout's <head>), with is:inline so Astro emits the tag as written. It defines the <tapback-bar> element and starts every bar on the page, however many there are:
<script is:inline type="module" async src="https://api.tapback.party/loader.js"
data-key="pk_live_…" data-api="https://api.tapback.party"></script>
Swap pk_live_… for your own key, or paste the tag from the Embed panel as it is.
Put a floating bar on each post
In src/pages/blog/[...slug].astro, inside the <BlogPost> slot, add one bar with layout="float", keyed to the same slug. It docks in the bottom corner wherever it sits in the markup, and it connects live, so readers see each other's reactions fall.
---
// src/pages/blog/[...slug].astro — the starter passes the entry as props;
// keep its imports (render, BlogPost) and getStaticPaths as they are
const post = Astro.props;
const { Content } = await render(post);
---
<BlogPost {...post.data}>
<Content />
<tapback-bar entity={`/blog/${post.id}/`} layout="float" />
</BlogPost>Add an inline bar to each post in the list
In the blog index (src/pages/blog/index.astro), give every post its own bar, keyed to each post's id (post.id on Astro 5 and later, post.slug on 4):
---
import { getCollection } from 'astro:content';
const posts = await getCollection('blog');
---
{posts.map((post) => (
<article>
<h2><a href={`/blog/${post.id}/`}>{post.data.title}</a></h2>
<p>{post.data.description}</p>
<tapback-bar entity={`/blog/${post.id}/`} layout="inline" live="off" />
</article>
))}
entity names the counter. On a list page it has to be set by hand: a bar without it infers the list page's own URL, so every blurb would share one tally. Emit the same value the post page uses and a reaction on the blurb lands on the same count as one on the post.
live="off" shows each blurb's count without opening a live socket for it; the falling reactions stay on the post page. Bars that load together share one session request (up to 50 bars each), so a reader can reload a 50-post index about ten times a minute; past a few hundred bars on one page, paginate — see Troubleshooting.
Different reactions per post (Plus)
By default every post shows your Tapbar's reactions. On Plus, a post can carry its own: add a named set in the console's Reactions card (say spooky, with a ghost and a skull), then point the post's bar at it.
{/* src/pages/blog/[...slug].astro, inside <BlogPost> */}
<tapback-bar entity={`/blog/${post.id}/`} layout="float" set={post.data.tapback_set} />
Add tapback_set: spooky to the post's front matter and tapback_set: z.string().optional() to the collection's schema in src/content.config.ts (z comes from astro/zod). Without the schema entry astro check fails and the field is stripped. Astro leaves an attribute off when its value is undefined or null, renders false as set="false" and an empty string as a bare set, so leave the field out of a post rather than writing tapback_set: ''. To list reactions on the bar instead of naming a set, use reactions="ghost,skull"; the keys have to be on the Tapbar or in its palette.
The list-page bars need no set. A live="off" bar that declares nothing never decides a post's reactions, so the post page's attribute decides them however readers arrive. The attribute applies the first time anyone loads the post; to change a post that's already live, use the ☰ picker in the console's Pages tab or the set_entity_reactions MCP tool. Changing reactions on live pages has the full rules.
To choose a post's reactions by looking at the draft instead, add the in-page picker to the draft render: gate the editor <script> on import.meta.env.DEV in BaseHead.astro, and render <tapback-editor> in [...slug].astro behind the same check.
Check it works
- Deploy to a site on the Tapbar's allowed list (or run your dev server, with
http://localhost:*allowed). The bar only runs on allowed sites. - Open a post, tap a reaction, and reload. The count is still there.
- Open the post list. That post's blurb shows the same count.
If no bar appears, check that the loader tag is in that page's <head> and that the page's origin is allowed — www and the bare domain are separate entries. Troubleshooting maps each symptom to its fix.
Notes for Astro
- Build the entity from the slug the same way the
hrefis built, so the index and post pages agree. - On Astro 5 and later the entry's id is
post.id;post.slugis undefined there and renders every bar as/blog/undefined/. Usepost.slugonly on Astro 4 or a legacy collection. - Keep
is:inlineso Astro emits the tag exactly as written: Astro processes the plain<script>tags it finds in components, andis:inlineopts this one out. astro checkneedsnpm i -D @astrojs/check typescriptthe first time.
Let your agent do it
Connect your agent to the Tapback MCP server — in Claude Code, claude mcp add --transport http tapback https://api.tapback.party/mcp; in Claude Desktop or claude.ai, Add custom connector with https://api.tapback.party/mcp — then paste this prompt:
Add Tapback live reactions to my Astro site.
1. Connect to the Tapback MCP server at https://api.tapback.party/mcp and let me approve the sign-in.
2. Ask me for my site's domain, then create a Tapbar with that domain as its allowed site. Give it a heart, a star, and a smile to start — I can change these later.
3. Show me the embed snippet and tell me exactly where it goes in Astro: the loader `<script>` in the shared `<head>` (`src/components/BaseHead.astro` in the blog starter, or your layout's `<head>`), with `is:inline` so Astro emits the tag as written; an inline bar (`layout="inline"`, `live="off"`) in the blog index (`src/pages/blog/index.astro`), keyed to each post's id (`post.id` on Astro 5 and later, `post.slug` on 4); and a floating bar (`layout="float"`) in `src/pages/blog/[...slug].astro`, inside the `<BlogPost>` slot, keyed to the same slug. Build the entity from the slug the same way the `href` is built, so the index and post pages agree. The Astro guide is at https://docs.tapback.party/install/astro/ (as markdown: https://docs.tapback.party/install/astro/index.md).
4. Once I've deployed, post a test reaction and read the count back so we know it's working.Set up with your agent has the same prompt for every stack, with an optional step for the in-page picker. Manage from your agent lists everything the agent can reach.