Skip to Content
🎉 Coral x Panda has been released 🎉 Read the Migration Guide

useTrustPilot

Basic Usage

There may be instances where you want to fetch the TrustPilot data, but have more control over the rendering instead of using the pre-built molecule. You can make use of the useTrustPilot hook to fetch the data and render outside of the molecules constraints.

import { useTrustPilot } from '@krakentech/coral-molecules'; const { loading, stars, trustScore, numberOfReviews, listOfReviews, updatedAt, } = useTrustPilot('oegb', true); return loading ? ( <>Loading...</> ) : ( <> <TrustPilotLogo width={200} /> <TrustPilotStars stars={stars} /> <Typography variant="caption">Updated {updatedAt}</Typography> <Typography variant="caption">Raw score: {trustScore}</Typography> <Typography variant="caption"> Review count: {numberOfReviews} </Typography> <Typography variant="caption"> Example Customer Review: {listOfReviews?.[0].text} </Typography> </> );
Loading...

Full API

Arguments

NameDescriptiontypeDefault valueRequired
businessAcronymThe buiness unit to get TrustPilot data forTrustPilotBusinessAcronymoegbtrue
withReviewsWhether the api response should include the 20 most recent 5 star reviewsbooleanfalsefalse

Return

NameDescriptiontype
loadingAre we waiting the TrustPilot API call to return data?boolean
starsHow many star SVGs should the consumer render?number
trustScoreWhat is the raw TrustPilot score?number
numberOfReviewsTotal number of reviewsstring
updatedAtAn ISO formatted date stringstring
listOfReviewsAn array of the 20 most recent 5 star reviewsReview[]
Last updated on