Skip to content

ProductReviews

A product's approved reviews: the summary, the page of reviews the URL asks for, filtered to a rating where it asks, and links to the pages around it. Renders nothing without reviews. Server-renderable; place it in the reviews section.

import { ProductReviews } from "@evolve-storefront/feature-product/product-reviews";

Renders inside ProductListingProvider.

Preview

DefaultOpen in Storybook ↗

Usage

The average and its spread beside the reviews; each rating links to the list filtered to it.

const params = readReviewParams(searchParams);
<ProductDetailSection id="reviews">
<ProductReviews
summary={await readProductReviewSummary(client, { slug })}
page={await readProductReviews(client, { slug, params })}
params={params}
search={searchParams}
pathname={pathname}
renderLink={({ href, children, ...props }) => <Link href={href} {...props}>{children}</Link>}
/>
</ProductDetailSection>;

Props

PropTypeDescription
summaryProductReviewSummary | null

readProductReviewSummary's result; renders nothing without it.

pageProductReviewPage | null

readProductReviews' page for the URL's readReviewParams.

paramsReviewParams
searchstring | URLSearchParams
pathname?string
renderLink?ProductReviewsLinkRenderer
headingLevel?HeadingLevel

The level of each review's title; the section around it is the site's.

Any other props go to the root element, like on a plain HTML element.

Change the layout

Pass children to ProductReviews to arrange its parts yourself. Every part is exported from @evolve-storefront/feature-product/product-reviews.

ProductReviewItemOne approved review: its rating, title and text, who wrote it and when, what they bought and how it fit.
PropTypeDescription
reviewProductReview
headingLevel?HeadingLevel
ProductReviewsFitHow the size fits by the reviews: the fit most buyers report and their share, such as "72% say it is true to size".
PropTypeDescription
fitDistribution{ fit: ProductReviewFit; count: number; }[]

The summary's fitDistribution, from Product.reviewFitDistribution.

Any other props go to the root element, like on a plain HTML element.

ProductReviewsSummaryThe average rating and how many reviews it comes from, the spread over 5 down to 1 stars, each a link filtering the list to it, and how the size fits where buyers were asked.
PropTypeDescription
summaryProductReviewSummary
searchstring | URLSearchParams

The URL's parameters, so the rating links keep the chosen variant.

rating?number

The rating the list is filtered by, marked in the spread.

pathname?string
renderLink?ProductReviewsLinkRenderer

Any other props go to the root element, like on a plain HTML element.

Examples

Filtered By RatingFiltered to a rating: that rating is marked, and its link shows every review again.
<ProductReviews {...props} params={readReviewParams(searchParams)} />;
Open in Storybook ↗