Embedding

React SDK

Components and hooks from @vlozi/blog/engage.

npm install @vlozi/blog

Everything lives under @vlozi/blog/engage. It's a self-contained client island — no API key, no VloziClient, importable on its own in a plain Next.js, Vite or CRA app even if you use nothing else from the SDK.

Setup

Wrap once, as high as is convenient:

import { EngagementProvider } from "@vlozi/blog/engage";
 
<EngagementProvider config={{ siteId: "site_abc123" }}>
  {children}
</EngagementProvider>
Option
siteId required — from Dashboard → Engagement → Sites
baseUrl defaults to https://api.vlozi.app

Counting

<EngagementBeacon target={`post:${post.id}`} />
<ViewCount target={`post:${post.id}`} />

<EngagementBeacon> renders nothing. It fires one view on mount, then a single read once the reader has actually dwelled and scrolled — that second signal is the interesting one.

<ViewCount> shows the number, with an optimistic +1 so a reader who just triggered a view doesn't see a count that visibly excludes them.

<ViewCount target={target} hideBelow={50} render={(n) => <b>{n.toLocaleString()} reads</b>} />

Reactions and ratings

<Reactions target={target} kinds={["like"]} />
<StarRating target={target} />
<Helpful target={target} />

Every kind must be switched on in Settings → Reactions, or the vote is rejected. <Helpful> is two ordinary, mutually exclusive kinds (helpful_yes / helpful_no), so enable both.

A visitor id is created in localStorage on their first interaction — never on a plain page view. A reader who only reads gets nothing written to their browser.

Comments

<Comments target={target} />

The full thread: list, one level of replies, a form with a honeypot, Turnstile when configured, a report link, and a five-minute window to fix your own typo.

Prop
title heading, or null
readOnly list without a form
pendingMessage copy after a comment is held
subscribeLabel newsletter opt-in label (only appears when you've configured a form)
signInPrompt copy above sign-in on member-only sites

Comment bodies render as plain text, never as HTML. That's not a limitation to work around — it's what stops a commenter injecting markup into your page. If you want links, render them yourself from useComments().

Reader sign-in

<SignInWithEmail />

Passwordless: the reader enters an email, gets a link, clicks it, and is signed in for 30 days. No password, no account, no cookie.

Set Settings → Comments → Verified readers to require it. On a guest site, signing in is just a convenience — their name and email are pre-filled, and they skip the first-time hold.

const { member, signIn, signOut, loading } = useMember();
<ReadingNow target={target} />
const { posts } = useTrendingPosts({ days: 7, limit: 5 });

<ReadingNow> hides itself below two readers — "1 person reading this" is almost always the reader themselves. It polls every 30 seconds and stops entirely while the tab is hidden.

Hooks

useEngagementSummary(keys) counts for many targets, batched into one request
useReaction(target, kind) this visitor's own vote, with optimistic updates
useComments(target) thread, submit, flag, edit
useMember() the signed-in reader
useTrendingPosts(opts) most-viewed, with titles
useEngageSiteConfig() your site's public settings

Batching

Every <ViewCount> mounted in one render shares a single request. A twelve-post index page costs one GET /summary, not twelve. You don't have to do anything to get this.

Bundle size

The engage island has a hard 8 KB brotli budget, checked in CI. It's deliberately independent of @vlozi/blog/react so importing a view counter doesn't pull in the whole blog renderer.

Structured data

import { engagementJsonLd } from "@vlozi/blog/engage";
 
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify({
  "@type": "BlogPosting", ...articleFields, ...engagementJsonLd(post, summary),
}) }} />

This emits comment counts and interaction counts — and deliberately not aggregateRating. Star ratings on your own article count as self-serving review markup: Google ignores it, and repeat offenders get a manual action. If you're rating a product (a collection entry someone buys), use productRatingJsonLd instead, which is the case the schema is actually for.

Engagement · EmbeddingEdit on GitHub