#Show reviews on your site
Show your TheHackStack rating and reviews on your own website, the way Google reviews appear on other sites. Pick a format: a carousel, a grid of cards, a list, or a small rating badge. Paste two lines and the widget keeps itself up to date.
- Uses the same script and key as your Review button.
- Shows your average rating, the number of reviews, and each review with the reviewer's name, stars, date and the green Verified tick.
- Includes a Write a review button that opens your product's review form.
- Looks right on any site: it is drawn in its own isolated area, so your page's CSS can't break it and it can't affect your page. Works on phones, supports dark mode.
#See it live
Switch formats and themes to see how the widget looks on a website. Signed in? The demo shows your product's real reviews.
Loading the live demo…
Want to try it on your computer? Save the example website's
index.html and
styles.css into one folder, replace
ths_pk_k1_YOUR_PUBLISHER_KEY in index.html with your key, and open
index.html in your browser. It shows every format on a sample landing page.
#Quick start
Paste this where the reviews should appear:
<script src="https://thehackstack.com/sdk/v1/ths-reviews.js"
data-key="ths_pk_k1_YOUR_PUBLISHER_KEY" async></script>
<div data-ths-reviews="carousel"></div>Already have the script on the page for your Review button? Then add only the
<div> line. One script serves any number of buttons and widgets.
Signed in on this site? The samples on this page use your real key. Your key is also in the Developer section on TheHackStack, with these snippets ready to copy.
#Formats
Set the format with the value of data-ths-reviews.
#Carousel
A horizontal slider of review cards with arrows; swipe on phones. Good for a home page or pricing page.
<div data-ths-reviews="carousel"></div>#Grid
Cards in a responsive grid: three or more columns on wide screens, one on phones. Good for a dedicated "Reviews" or "Testimonials" page.
<div data-ths-reviews="grid" data-limit="9"></div>#List
Reviews stacked one under another. Good for a sidebar or a narrow column.
<div data-ths-reviews="list" data-limit="5"></div>#Rating badge
A compact pill such as 4.8 ★★★★★ 23 reviews | TheHackStack that links to your reviews on TheHackStack. Good for a header, footer or next to a "Buy" button.
<div data-ths-reviews="badge"></div>The carousel, grid and list start with a summary: your average rating, stars, "Based on N reviews" and how many are Verified, plus the Write a review button. They end with a small "Powered by TheHackStack" link.
#Options
Add these attributes to the <div>:
| Attribute | Values | Default | What it does |
|---|---|---|---|
data-ths-reviews |
carousel, grid, list, badge |
carousel |
The format. |
data-limit |
1–20 | 6 |
How many reviews to show. |
data-verified-only |
present or absent | absent | Show only Verified reviews. |
data-min-rating |
1–5 | 1 |
Show only reviews with at least this many stars. |
data-sort |
recent, top |
recent |
Newest first, or highest rating first. |
data-theme |
light, dark, auto |
auto |
auto follows the visitor's light or dark setting. |
The summary (average and count) always covers all your reviews, whatever filters you choose, so it stays honest.
<!-- Only 4- and 5-star Verified reviews, best first, on a dark page -->
<div data-ths-reviews="grid"
data-limit="6"
data-verified-only
data-min-rating="4"
data-sort="top"
data-theme="dark"></div>#Size and placement
The widget fills the width of the element you put it in. To make it narrower,
put it inside a container with a max-width, for example
<section class="reviews"> with .reviews { max-width: 960px; margin: auto; }
in your own stylesheet.
#Pinned version with Subresource Integrity
For the strictest setups, load the pinned release instead of the latest 1.x:
<script src="https://thehackstack.com/sdk/v1.2.0/ths-reviews.js"
integrity="sha384-rSq3igDf1LtE8FQQEWmUsDIdvfJwHKXsykIji4SSHzwGhlGzhpMp6zPhb30s13Rb"
crossorigin="anonymous"
data-key="ths_pk_k1_YOUR_PUBLISHER_KEY" async></script>#Content-Security-Policy
If your site sends a Content-Security-Policy header, allow TheHackStack:
script-src https://thehackstack.com;
connect-src https://thehackstack.com;
style-src https://thehackstack.com;
img-src https:;img-src is for reviewers' profile photos. Without it, initials are shown
instead.
#Single-page apps and JavaScript
Widgets added to the page after it loads (React, Vue, Angular and so on) need a
call to mountReviews(), or render one directly:
// after your component has rendered <div data-ths-reviews="grid"></div>
THSReviews.mountReviews();
// or without the data attributes
THSReviews.renderReviews(document.querySelector('#reviews'), {
format: 'carousel', // 'carousel' | 'grid' | 'list' | 'badge'
limit: 8,
verifiedOnly: false,
minRating: 1,
sort: 'recent', // 'recent' | 'top'
theme: 'auto', // 'light' | 'dark' | 'auto'
}).catch((err) => console.warn(err.code));If you load the script without data-key, call
THSReviews.init({ publisherKey: 'ths_pk_k1_YOUR_PUBLISHER_KEY' }) first.
#Build your own design
Want full control over the look? Read the same data from the public reviews API and render it yourself.
In the browser:
const url = 'https://thehackstack.com/api/v1/reviews?key=ths_pk_k1_YOUR_PUBLISHER_KEY&limit=6';
const data = await (await fetch(url)).json();
document.querySelector('#rating').textContent =
`${data.summary.average} out of 5 · ${data.summary.count} reviews`;
for (const review of data.reviews) {
const li = document.createElement('li');
li.textContent = `${'★'.repeat(review.rating)} ${review.author.name}: ${review.body}`;
document.querySelector('#reviews').append(li);
}On your server (PHP):
<?php
$url = 'https://thehackstack.com/api/v1/reviews?key=ths_pk_k1_YOUR_PUBLISHER_KEY&limit=6';
$data = json_decode(file_get_contents($url), true);
echo '<p>' . htmlspecialchars($data['summary']['average'] . ' / 5 · ' . $data['summary']['count'] . ' reviews') . '</p>';
foreach ($data['reviews'] as $review) {
echo '<blockquote>' . htmlspecialchars($review['body']) . '<cite>'
. htmlspecialchars($review['author']['name']) . '</cite></blockquote>';
}Always insert review text as text (textContent, htmlspecialchars), never as
raw HTML. Cache the response on your server for a few minutes rather than
calling the API on every page view.
#Good to know
- Which reviews appear: the reviews on your product's TheHackStack page. Deleted reviews disappear from the widget too.
- Updates: new reviews show up within about 5 minutes.
- Names: reviewers appear as first name and last initial, for example Priya S. Emails are never shown.
- No reviews yet: the widget shows "No reviews yet" with the Write a review button, so it's safe to add before your first review arrives.
- Replaced key: if you replace your key in the Developer section, update
data-keyin your snippet; the old key stops showing reviews. - Errors: if reviews can't be loaded, the widget stays empty and the SDK logs
reviews_unavailableto the console (see Error handling).