npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-algoliasearch-helper-vl

v1.2.2

Published

React `<Provider helper>` and `connect()(WrappedComponent)` for algoliasearch-helper

Readme

--- NOTE FROM MAINTAINERS --- (Sept 2016) We are working on react-instantsearch, it's already working. Ping me on twitter: https://twitter.com/vvoyer if you want to be an alpha tester

react-instantsearch is a react specific UI library for Algolia, much easier than react-algoliasearch-helper --- / NOTE FROM MAINTAINERS ---

react-algoliasearch-helper

Version Build Status License Downloads

React <Provider> and connect(WrappedComponent) for algoliasearch-helper.

Its goal is to make building React applications with Algolia easier by allowing easy access to the algoliasearch-helper.

Table of Contents

Install

npm install react-algoliasearch-helper --save

Example

SearchBox.js

import React from 'react';
import {connect} from 'react-algoliasearch-helper';

export default connect()(
  ({helper}) =>
    <input
      placeholder="Search here"
      autoFocus
      onChange={e => helper.setQuery(e.target.value).search()}
    />
);

Hits.js

import React, {PropTypes} from 'react';
import {connect} from 'react-algoliasearch-helper';

const Results = ({results}) => {
  if (!results) return <div/>;
  return <div>{results.hits.map(hit => <div key={hit.objectID}>{hit.Name}</div>)}</div>;
};

Results.propTypes = {
  results: PropTypes.object
};

export default connect(
  state => ({results: state.searchResults})
)(Results);

index.js

import React from 'react';
import ReactDOM from 'react-dom';
import algoliasearch from 'algoliasearch';
import algoliasearchHelper from 'algoliasearch-helper';
import {Provider} from 'react-algoliasearch-helper';
import SearchBox from './components/SearchBox.js';
import Hits from './components/Hits.js';

const client = algoliasearch('latency', 'ffc36feb6e9df06e1c3c4549b5af2b31');
const helper = algoliasearchHelper(client, 'starbucks');

const App = () =>
  <Provider helper={helper}>
    <div>
      <SearchBox/>
      <Hits/>
    </div>
  </Provider>;

ReactDOM.render(<App/>, document.querySelector('#root'));

API

<Provider helper>

Makes the Algolia Search helper available to the connect() calls in the component hierarchy below. You can’t use connect() without wrapping your root component in .

Props

Example

ReactDOM.render(
  <Provider helper={helper}>
    <MyRootComponent />
  </Provider>,
  rootEl
)

connect([mapStateToProps])(WrappedComponent)

Connects a React component to the helper.

Arguments

  • [mapStateToProps(state, ownProps): stateProps] (function): if specified, the component will subscribe to helper events (change, search, result, error). Allowing you to compute props for your wrapper component based on the search state.

Search state shape

Every function passed to mapStateToProps argument of connect will be given an search state object with those properties:

  • searching (boolean): true when a search request is pending, false otherwise
  • searchParameters (object): helper's SearchParameters
  • searchResults (object): helper's SearchResults
  • searchResultsSearchParameters (object): SearchParameters that yielded the current SearchResults
  • searchError (Error): When the search fails

Remarks

  • It needs to be invoked two times. The first time with its arguments described above, and a second time, with the component: connect([mapStateToProps])(WrappedComponent).
  • It does not modify the passed React component. It returns a new, connected component, that you should use instead.
  • Most probably, you will use connect as in export default connect()(WrappedComponent).

Examples

Forward helper to the RefinementList component:

export default connect()(RefinementList)

Receive results in the Hits component:

export default connect(
  state =>
    ({
      results: state.searchResults
    })
)(Hits) // Hits component will receive a `results` property everytime new results are available

Tests

Tests are written with Jest.

npm test
npm run test:watch
npm run lint

Dev

npm start

Release

npm run release