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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tefkah/chair-flight-docsearch-react

v3.0.5

Published

A clone of a clone of Algolia's React DocSearch, but it accepts any search backend and is incompatible with IE.

Downloads

4

Readme

chair-flight Docsearch React

A clone of Algolia's React DocSearch, but it accepts any search backend, AND IS INCOMPATIBLE WITH IE, in order not to have to polyfill regeneratorRuntime.

Installation

yarn add @tefkah/chair-flight-docsearch-react
# or
npm install @tefkah/chair-flight-docsearch-react

Get started

The api for the component is pretty much the same as the original docsearch-react except that instead of providing an appId and apiKey you are supposed to pass an arbitrary search function:

import { DocSearch } from '@tefkah/chair-flight-docsearch-react';

import '@docsearch/css';

function App() {
  return (
    <DocSearch
      search={async (queryString) =>
        myCustomBackend.search(queryString).map(toDocSearchHit)
      }
      indexName="YOUR_INDEX_NAME_USED_FOR_LOCAL_CACHE_PURPOSES"
    />
  );
}

export default App;

The search function is expected to return an array of DocSearchHit, the internal type used by algolia documents. You will most likely have to write a function mapping your search results into this specific format:

export declare type DocSearchHit = {
  objectID: string;
  content: string | null;
  url: string;
  url_without_anchor: string;
  type: ContentType;
  anchor: string | null;
  hierarchy: {
    lvl0: string;
    lvl1: string;
    lvl2: string | null;
    lvl3: string | null;
    lvl4: string | null;
    lvl5: string | null;
    lvl6: string | null;
  };
  _highlightResult: DocSearchHitHighlightResult;
  _snippetResult: DocSearchHitSnippetResult;
  _rankingInfo?: {
    promoted: boolean;
    nbTypos: number;
    firstMatchedWord: number;
    proximityDistance?: number;
    geoDistance: number;
    geoPrecision?: number;
    nbExactWords: number;
    words: number;
    filters: number;
    userScore: number;
    matchedGeoLocation?: {
      lat: number;
      lng: number;
      distance: number;
    };
  };
  _distinctSeqID?: number;
};

Note: the search engine is fairly robust. Most of these params can be considered optional with no decrease of functionality.

Documentation

All other features are inline with docsearch, so I advise you to look in the original docs:

Read documentation →