Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-instantsearch

Package Overview
Dependencies
Maintainers
7
Versions
217
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-instantsearch

⚡ Lightning-fast search for React, by Algolia

  • 7.5.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
202K
decreased by-3.08%
Maintainers
7
Weekly downloads
 
Created

What is react-instantsearch?

react-instantsearch is a library that provides a set of React components and connectors to build search interfaces using Algolia's search engine. It allows developers to create highly customizable and performant search experiences with minimal effort.

What are react-instantsearch's main functionalities?

SearchBox

The SearchBox component provides a search input field that users can type into to perform searches. It is a fundamental part of any search interface.

import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom';
import algoliasearch from 'algoliasearch/lite';

const searchClient = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey');

function App() {
  return (
    <InstantSearch searchClient={searchClient} indexName="your_index_name">
      <SearchBox />
      <Hits />
    </InstantSearch>
  );
}

export default App;

Hits

The Hits component displays the search results. You can customize how each hit is rendered by providing a custom hitComponent.

import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom';
import algoliasearch from 'algoliasearch/lite';

const searchClient = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey');

function Hit({ hit }) {
  return (
    <div>
      <h2>{hit.title}</h2>
      <p>{hit.description}</p>
    </div>
  );
}

function App() {
  return (
    <InstantSearch searchClient={searchClient} indexName="your_index_name">
      <SearchBox />
      <Hits hitComponent={Hit} />
    </InstantSearch>
  );
}

export default App;

RefinementList

The RefinementList component allows users to filter search results based on specific attributes, such as categories. This helps in narrowing down the search results.

import { InstantSearch, SearchBox, Hits, RefinementList } from 'react-instantsearch-dom';
import algoliasearch from 'algoliasearch/lite';

const searchClient = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey');

function App() {
  return (
    <InstantSearch searchClient={searchClient} indexName="your_index_name">
      <SearchBox />
      <RefinementList attribute="categories" />
      <Hits />
    </InstantSearch>
  );
}

export default App;

Pagination

The Pagination component provides navigation through pages of search results, making it easier for users to browse through large sets of data.

import { InstantSearch, SearchBox, Hits, Pagination } from 'react-instantsearch-dom';
import algoliasearch from 'algoliasearch/lite';

const searchClient = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey');

function App() {
  return (
    <InstantSearch searchClient={searchClient} indexName="your_index_name">
      <SearchBox />
      <Hits />
      <Pagination />
    </InstantSearch>
  );
}

export default App;

Other packages similar to react-instantsearch

Keywords

FAQs

Package last updated on 06 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc