Quick Start Guides

Guides to quickly get started with this mattie-bundle for Strapi.

Checkout the example in the mattie-bundle monorepo.

Search plugin with Algolia provider

1. Strapi application

yarn create strapi-app search-with-algolia --quickstart
npx create-strapi-app search-with-algolia --quickstart
Initial Admin user

2. Create a Post collection type

After registering the initial Admin user, we can use the Content-Type Builder to create our first collection type Post. Create a new collection type with the following configurations and example fields:

Post collection type configurations Post collection type fields

Save the collection type and wait for the server to restart.

3. Sign up and create your Algolia application

Create your Algolia by signing up at algolia.com/users/sign_up. Once you have created you Algolia application, navigate to Settings > Team and Access > API Keys (algolia.com/account/api-keys).

Algolia API keys settings

Add your Application ID and Admin API Key to ./.env file in your project.

// ...
ALGOLIA_PROVIDER_APPLICATION_ID=G9Z63O9QUF
ALGOLIA_PROVIDER_ADMIN_API_KEY=043d7•••••••••••••••••••••••8102

4. Install plugin and provider

Stop your Strapi application, navigate to your strapi project with cd search-with-algolia in your terminal and install the Search plugin and the Algolia provider packages with:

yarn add @mattie-bundle/strapi-plugin-search @mattie-bundle/strapi-provider-search-algolia
npm install @mattie-bundle/strapi-plugin-search @mattie-bundle/strapi-provider-search-algolia

5. Configure the plugin and provider

Add the Search plugin and Algolia provider configuration to the ./config/plugins.js file. Create the file if it doesn't exist yet.

'use strict';

module.exports = ({ env }) => ({
  // ...
  search: {
    enabled: true,
    config: {
      provider: 'algolia',
      providerOptions: {
        apiKey: env('ALGOLIA_PROVIDER_ADMIN_API_KEY'),
        applicationId: env('ALGOLIA_PROVIDER_APPLICATION_ID'),
      },
      contentTypes: [
        { name: 'api::post.post' },
      ],
    },
  },
});

6. Index an Post entity

Let's start the Strapi server with yarn develop or npm run develop and create the first Post entity. After the server has started go to the admin panel (http://localhost:1337/admin) and navigate to Content Manager > COLLECTION TYPES > Post and click on + Create new Entry. Now create your first Post and hit Save and Publish to also index this entry into your Algolia Application.

Create first Post entry

Now the entry is saved, check your Algolia application if it has been indexed successfully.

First Post entry indexed
Edit this page on GitHub Updated at Fri, Dec 31, 2021