React SDK

Hooks

SizeLatest NPM version

Hooks that allow you to build a search interface using any component library.

Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class.

1. Install

Install the dependency via yarn or npm install.

2. Import

Pick and choose the components you'd like to use and import them.

In this basic example, we'll also use components from the @sajari/react-components package:

3. Pipeline

A Pipeline is required to perform search queries. For this example, we'll use a demo pipeline using a Best Buy data set. Replace the values from your collection credentials.

4. App

Use them in your app.

5. SearchProvider

The SearchProvider should be used as a wrapper for the entire application to provide a way to share application state between hooks, for example, the current query, active filters or the search response. See SearchProvider for more information.

Completed example

Editable Example
Suggestions
    Powered by