Skip to content

flapjackhq/flapjack-search-javascript

Repository files navigation

Flapjack for JavaScript

The perfect starting point to integrate Flapjack within your JavaScript project

NPM version NPM downloads jsDelivr Downloads License

DocumentationInstantSearchCommunity ForumStack OverflowReport a bugSupport

✨ Features

  • Thin & minimal low-level HTTP client to interact with Flapjack's API
  • Works both on the browser and node.js
  • UMD and ESM compatible, you can use it with any module loader
  • Built with TypeScript

💡 Getting Started

To get started, you first need to install flapjack-search (or any other available API client package). All of our clients comes with type definition, and are available for both browser and node environments.

With a package manager

yarn add flapjack-search@0.1.0-beta.1
# or
npm install flapjack-search@0.1.0-beta.1
# or
pnpm add flapjack-search@0.1.0-beta.1

Without a package manager

Add the following JavaScript snippet to the of your website:

<script src="https://cdn.jsdelivr.net/npm/flapjack-search@0.1.0-beta.1/dist/flapjack-search.umd.js"></script>

Usage

You can now import the Flapjack API client in your project and play with it.

import { flapjackSearch } from 'flapjack-search';

const client = flapjackSearch('YOUR_APP_ID', 'YOUR_API_KEY');

Self-hosted server

const client = flapjackSearch('my-app', 'my-api-key', {
  hosts: [{ url: 'search.example.com', protocol: 'https', accept: 'readWrite' }],
});

Drop-in InstantSearch compatibility

Flapjack Search works with the entire Algolia InstantSearch ecosystem — no widget changes needed:

import { flapjackSearch } from 'flapjack-search';
import instantsearch from 'instantsearch.js';
import { searchBox, hits } from 'instantsearch.js/es/widgets';

const search = instantsearch({
  searchClient: flapjackSearch('APP_ID', 'API_KEY'),
  indexName: 'products',
});
search.addWidgets([searchBox({ container: '#search' }), hits({ container: '#hits' })]);
search.start();

Works with React InstantSearch, Vue InstantSearch, and Autocomplete.js too. See the migration guide for details.

Migrating from Algolia?

Switching takes about 5 minutes:

  1. npm uninstall algoliasearch && npm install flapjack-search@0.1.0-beta.1
  2. Replace import algoliasearch from 'algoliasearch' with import { flapjackSearch } from 'flapjack-search'
  3. Replace algoliasearch( with flapjackSearch(
  4. Done — all methods, types, and widgets work identically.

❓ Troubleshooting

Encountering an issue? Open a GitHub issue and we'll help.

📄 License

The Flapjack JavaScript API Client is an open-sourced software licensed under the MIT license.

About

Flapjack Search JavaScript/TypeScript SDK — drop-in replacement for algoliasearch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors