# Custom HTML Review Widgets

Here is a quick example of a DIY solution for review widgets using React.

Notice how you still perform an API call to the Aggregation API and display data however you want in your app.

### React.js

```jsx
import React from 'react'

const BusinessPage = () => {
  const [reviews, setReviews] = React.useState([]);

  React.useEffect(() => {
    // ** 1
    // This call is your backend endpoint which pulls reviews 
    // from Cloutly API for the given business ID.
    getReviewsForBusiness("BUSINESS_ID", options)
      .then((data) => setReviews(data));
  }, []);

 // ** 2
 // You can display reviews however you like using your own components
  return (
     <div>
       MY Business
       {reviews && <CustomReviewComponent reviews={reviews}/>}
     </div>
  );
}

const MyApp = () => {
  return (
    <MainApp>
      <head>
        <title>Your Marketplace Website</title>
      </head>
      <BusinessPage />
    </MainApp>
  );
};
```

### Next.js

Example: Use `getServerSideProps` to render review data server-side dynamically.

```jsx
import React from 'react'

function Page({ data }) {
  // Render review data...
}

// This gets called on every request
export async function getServerSideProps(context) {
  const { id } = context.params; // Get Business ID from slug `/business/1`

  // Fetch data from Cloutly API
  const reviews = await fetchReviews(id);

  // Pass data to the page via props
  return { props: { data: reviews } }
}

export default Page
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloutly.com/reviews-sdk-for-marketplace-websites/widgets-sdk/custom-html.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
