TheHackStack Docs Sign in

#Leave a Review integration

The Leave a Review button sends any visitor straight to the review form for your product on TheHackStack. It needs no backend code and no API key, so you can show it to everyone. Reviews left through your button or link get the green Verified badge: they came from your own website or app, and the reviewer has a confirmed TheHackStack email. To vouch for one specific signed-in customer from your server instead, use Verify Your Review.

#Get your key

Open Developer (/developer/apps) from your account menu on TheHackStack and pick your product. Its key (ths_pk_k1_…) and a ready-to-paste snippet are already there. Each product has its own key, and nothing needs to be registered or verified first. Signed in on this site? The samples below are filled in with your key.

The key is public: it goes into your HTML. It is encrypted, so only TheHackStack can read what it identifies (your app, product and domain), and it can't be edited or forged. You can revoke a key and generate a new one at any time; revoked keys stop working immediately.

#Add the button

<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>

<button data-ths-review-button="leave">Review us on TheHackStack</button>

Or from code:

THSReviews.init({ publisherKey: 'ths_pk_k1_YOUR_PUBLISHER_KEY' });
document.querySelector('#review-us').addEventListener('click', () => THSReviews.leaveReview());

No JavaScript? Link to the review page directly: https://thehackstack.com/r/<your publisher key>.

#How it works

  1. On click, the SDK opens https://thehackstack.com/r/<publisher key>.
  2. TheHackStack decrypts and checks the key (the key and your application must be active), then mints a temporary token (ths_rt_…). The token is encrypted and names the application, the account that owns it, the product and its review page.
  3. Signed-in visitor: they land on your product's review form.
  4. Not signed in: the token is kept in their session and in the browser's local storage on thehackstack.com, and they're asked to sign in or create an account. Right after they log in or sign up (or confirm their email, even in another tab), TheHackStack validates the token again and opens your product's review form. They never have to look for your product.
  5. The token is not single-use. It keeps working until it expires (two hours), and your key keeps working for every visitor. Each person has one review per product; writing again updates it.
  6. Reviews written this way are attributed to your application, so you can see in the Developer section how many reviews came from your integration.

#With an app id (SDK 1.0 behaviour)

data-app-id="ths_app_…" still works. Without a publisher key the SDK loads your public configuration and sends visitors to your product's #reviews section instead of the form:

  1. On click, the SDK requests your app's public configuration: GET https://thehackstack.com/api/v1/apps/<appId>/sdk-config (see the API reference).
  2. It checks that the returned review_url is on https://thehackstack.com.
  3. It navigates to your product page's #reviews section. The visitor signs in to TheHackStack if needed and writes their review there.

The configuration request is sent without cookies, and the result is cached for the page's lifetime.

#Allowed origins

This applies only to the app-id mode; publisher-key links don't call the configuration endpoint. The configuration endpoint answers browsers only on:

  • https://<your-product-domain> and https://www.<your-product-domain>;
  • additional https:// origins you add under app Settings (see App registration).

On any other origin the server returns 403 origin_not_allowed, and unknown or inactive apps return 404 not_found. These refusals carry no CORS headers, so the browser hides them from the page: the SDK reports network_error, and the browser console shows a CORS error for the sdk-config request. To tell this apart from a real connection problem, open the request in your browser's Network tab and check its status (403 or 404).

#Errors

err.code Cause Fix
network_error Page origin not allowed, app not active, or a connectivity problem Check the sdk-config request in the Network tab: 403 → add the origin under Settings (it must be https://); 404 → check the app status; no response → retry
timeout Connectivity Safe to retry
config_unavailable TheHackStack answered with an error that the page was allowed to read (rare, e.g. a temporary server error) Retry later; check app status if it persists
invalid_response Unexpected configuration Make sure baseUrl (if set) is https://thehackstack.com
API and SDK served from https://thehackstack.com. Report security issues privately to the TheHackStack team.