Skip to content

Latest commit

 

History

History

create-instantsearch-app

Create InstantSearch App

⚡️ Build InstantSearch apps at the speed of thought.

Version License Build Status

create-instantsearch-app is a command line utility that helps you quick start your InstantSearch app using any Algolia InstantSearch flavor (InstantSearch.js, React InstantSearch, Vue InstantSearch, InstantSearch iOS and InstantSearch Android).

Preview

Contents

Get started

The tool requires Node ≥ 8.

npx create-instantsearch-app my-app
cd my-app
npm start

npx is a tool introduced in npm@5.2.0 that makes it possible to run CLI tools hosted on the npm registry.


Alternatively, you can use Yarn:

yarn create instantsearch-app my-app
cd my-app
yarn start

Important Selecting 'Y' when being prompted to ‘Enable user events’ activates the insights option for compatible templates, allowing Algolia to process your user Events. Events can unlock powerful features, enhancing your application's effectiveness and we encourage you to consider enabling this valuable functionality. Please review our API reference for more details about Events collection and settings.

Usage

This package comes with the module createInstantSearchApp(path, options?) and the command-line tool create-instantsearch-app.

$ create-instantsearch-app --help

  Usage: create-instantsearch-app <project-directory> [options]

  Options:

    -v, --version                                      output the version number
    --name <name>                                      The name of the application
    --app-id <appId>                                   The application ID
    --api-key <apiKey>                                 The Algolia search API key
    --index-name <indexName>                           The main index of your search
    --attributes-to-display <attributesToDisplay>      The attributes of your index to display
    --image-attribute <imageAttribute>                 The attribute of your index to use for image display
    --attributes-for-faceting <attributesForFaceting>  The attributes for faceting
    --template <template>                              The InstantSearch template to use
    --library-version <libraryVersion>                 The version of the library
    --config <config>                                  The configuration file to get the options from
    --no-installation                                  Ignore dependency installation
    --no-interactive                                   Do not ask any interactive questions
    -h, --help                                         output usage information

--template

Supported templates are:

create-instantsearch-app my-app --template "React InstantSearch"

You can also create your own template and specify its path.

--config

The config flag is handy to automate app generations.

config.json
{
  "name": "my-app",
  "template": "InstantSearch.js",
  "libraryVersion": "2.8.0",
  "appId": "MY_APP_ID",
  "apiKey": "MY_API_KEY",
  "indexName": "MY_INDEX_NAME",
  "searchPlaceholder": "Search",
  "attributesToDisplay": ["name", "description"],
  "imageAttribute": "image",
  "attributesForFaceting": ["brand", "location"],
  "enableInsights": true
}

Create the app based on this configuration:

create-instantsearch-app my-app --config config.json

API

create-instantsearch-app is based on the module createInstantSearchApp(path, options?). The same camel cased options as the CLI are available.

const createInstantSearchApp = require('create-instantsearch-app');

const app = createInstantSearchApp('~/lab/my-app', {
  template: 'InstantSearch.js',
  libraryVersion: '2.0.0',
  attributesToDisplay: ['name', 'description'],
  imageAttribute: 'image',
  attributesForFaceting: ['keywords'],
  enableInsights: true,
});

app.create().then(() => console.log('App generated!'));

Tutorials

Previews

You can use the web templates on CodeSandbox:

Contributing

We welcome all contributors, from casual to regular 💙

To start contributing to the code, you need to:

  1. Fork the project
  2. Clone the repository
  3. Install the dependencies: yarn

Please read our contribution process to learn more.

License

Create InstantSearch App is MIT licensed.