wkentdag

payload plugin algolia

by wkentdag
Search
v3
^3.0.0
MIT

Overview

Summary generated from the README

Syncs documents from selected Payload collections to an Algolia index using collection hooks. Configure it with Algolia credentials and a list of collection slugs in the plugins array. Requires Payload 3.x. Drafts are not indexed, and unpublishing a document removes it from the index.

Features

  • Indexes enabled collections in Algolia on create, update and delete
  • Sends the full document with an objectID and collection key by default
  • Custom generateSearchAttributes function to shape each record
  • Optional waitForHook setting to await Algolia operations in hooks
  • Removes unpublished documents from search results

Use cases

  • Add fast hosted search to a Payload-powered site with Algolia
  • Index posts and pages together with enriched fields such as image URLs

From the author

Algolia search plugin for PayloadCMS

Installation

npm i payload-plugin-algolia

17

Stars

3

Forks

4

Open Issues

5 months ago

Last Updated

124

Weekly Downloads

v1.0.2

npm Version

26.3 KB

Unpacked Size

1

Dependencies

GitHub stars

170 since Sep 7

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 202617
Dec 5, 202617
Dec 4, 202617
Dec 3, 202617
Dec 2, 202617
Dec 1, 202617
Nov 30, 202617
Nov 29, 202617
Nov 28, 202617
Nov 27, 202617
Nov 26, 202617
Nov 25, 202617
Nov 24, 202617
Nov 23, 202617
Nov 22, 202617
Nov 21, 202617
Nov 20, 202617
Nov 19, 202617
Nov 18, 202617
Nov 17, 202617
Nov 16, 202617
Nov 15, 202617
Nov 14, 202617
Nov 13, 202617
Nov 12, 202617
Nov 11, 202617
Nov 10, 202617
Nov 9, 202617
Nov 8, 202617
Nov 7, 202617
Nov 6, 202617
Nov 5, 202617
Nov 4, 202617
Nov 3, 202617
Nov 2, 202617
Nov 1, 202617
Oct 31, 202617
Oct 30, 202617
Oct 29, 202617
Oct 28, 202617
Oct 27, 202617
Oct 26, 202617
Oct 25, 202617
Oct 24, 202617
Oct 23, 202617
Oct 22, 202617
Oct 21, 202617
Oct 20, 202617
Oct 19, 202617
Oct 18, 202617
Oct 17, 202617
Oct 16, 202617
Oct 15, 202617
Oct 14, 202617
Oct 13, 202617
Oct 12, 202617
Oct 11, 202617
Oct 10, 202617
Oct 9, 202617
Oct 8, 202617
Oct 7, 202617
Oct 6, 202617
Oct 5, 202617
Oct 4, 202617
Oct 3, 202617
Oct 2, 202617
Oct 1, 202617
Sep 30, 202617
Sep 29, 202617
Sep 28, 202617
Sep 27, 202617
Sep 26, 202617
Sep 25, 202617
Sep 24, 202617
Sep 23, 202617
Sep 22, 202617
Sep 21, 202617
Sep 20, 202617
Sep 19, 202617
Sep 18, 202617
Sep 17, 202617
Sep 16, 202617
Sep 15, 202617
Sep 14, 202617
Sep 13, 202617
Sep 12, 202617
Sep 11, 202617
Sep 10, 202617
Sep 9, 202617
Sep 8, 202617
Sep 7, 202617
npm weekly downloads

125+46 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 2026125
Dec 5, 2026100
Dec 4, 202682
Dec 3, 202681
Dec 2, 202631
Dec 1, 202652
Nov 30, 202675
Nov 29, 202694
Nov 28, 2026103
Nov 27, 2026102
Nov 26, 2026107
Nov 25, 2026208
Nov 24, 2026194
Nov 23, 2026176
Nov 22, 2026232
Nov 21, 2026343
Nov 20, 2026363
Nov 19, 2026372
Nov 18, 2026364
Nov 17, 2026358
Nov 16, 2026376
Nov 15, 2026436
Nov 14, 2026785
Nov 13, 20262,066
Nov 12, 20262,651
Nov 11, 20262,937
Nov 10, 20263,017
Nov 9, 20263,371
Nov 8, 20263,975
Nov 7, 20263,681
Nov 6, 20262,511
Nov 5, 20261,990
Nov 4, 20261,636
Nov 3, 20261,556
Nov 2, 20261,192
Nov 1, 2026561
Oct 31, 2026469
Oct 30, 2026389
Oct 29, 2026305
Oct 28, 2026272
Oct 27, 2026271
Oct 26, 2026259
Oct 25, 2026154
Oct 24, 202694
Oct 23, 202636
Oct 22, 202653
Oct 21, 202662
Oct 20, 202661
Oct 19, 202658
Oct 18, 202660
Oct 17, 202665
Oct 16, 202670
Oct 15, 202665
Oct 14, 202680
Oct 13, 202683
Oct 12, 202683
Oct 11, 202698
Oct 10, 202696
Oct 9, 2026128
Oct 8, 2026153
Oct 7, 2026172
Oct 6, 2026169
Oct 5, 2026169
Oct 4, 2026159
Oct 3, 2026147
Oct 2, 2026136
Oct 1, 2026178
Sep 30, 2026180
Sep 29, 2026214
Sep 28, 2026214
Sep 27, 2026244
Sep 26, 2026265
Sep 25, 2026282
Sep 24, 2026230
Sep 23, 2026230
Sep 22, 2026207
Sep 21, 2026207
Sep 20, 2026183
Sep 19, 2026161
Sep 18, 2026145
Sep 17, 2026172
Sep 16, 2026183
Sep 15, 2026172
Sep 14, 2026190
Sep 13, 2026218
Sep 12, 2026211
Sep 11, 2026185
Sep 10, 2026135
Sep 9, 202693
Sep 8, 202693
Sep 7, 202679

Each point is npm's rolling 7-day download count.

Health Score

54/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/786237326-root.svg)](https://payloaddirectory.dev/plugins/786237326-root)
HTML
<a href="https://payloaddirectory.dev/plugins/786237326-root"><img src="https://payloaddirectory.dev/badge/786237326-root.svg" alt="Payload Directory"></a>
Updated Jul 8, 2026Created Apr 13, 2024Published Jul 8, 2026

README

payload-plugin-algolia

PayloadCMS plugin that syncs collections with Algolia search

ci status

Requires Payload 3.x (payload peer dependency).

Installation

npm i payload-plugin-algolia

Usage

At a minimum, the plugin requires Algolia credentials and a list of enabled collections.

// payload.config.ts

import { buildConfig } from 'payload'
import { AlgoliaSearchPlugin } from 'payload-plugin-algolia'
import Pages from './collections/Pages'
import Posts from './collections/Posts'

export default buildConfig({
  collections: [Pages, Posts],
  plugins: [
    AlgoliaSearchPlugin({
      algolia: {
        appId: process.env.ALGOLIA_APP_ID,
        apiKey: process.env.ALGOLIA_ADMIN_API_KEY,
        index: process.env.ALGOLIA_INDEX,
      },
      collections: ['pages', 'posts'],
    }),
  ],
  // ...more config
})

Options

generateSearchAttributes

By default, the plugin will pass the entire document through to Algolia, with two appended keys:

  • objectID: format ${collection}:${id} eg pages:1
  • collection: the collection slug

You can modify search attributes by providing a custom generateSearchAttributes function:

import { type GenerateSearchAttributes } from 'payload-plugin-algolia'

interface PageRecord {
  title: string
  text: string
}

interface PostRecord extends PageRecord {
  image: string
}

const generateSearchAttributes: GenerateSearchAttributes<PageRecord | PostRecord> = async ({
  doc,
  collection,
  req: { payload },
}) => {
  switch (collection.slug) {
    case 'posts': {
      if (doc.featured_image) {
        const { url } = await payload.findByID({
          collection: 'media',
          id: doc.featured_image as number,
        })

        return {
          ...doc,
          image: url,
        }
      }

      return doc
    }
    default:
      return doc
  }
}

waitForHook

Boolean, default = false

Set to true to wait for algolia set / delete operations during the collection hooks.

Notes

The current scope of the plugin is quite limited. PRs welcome!

Drafts

Drafts are not indexed. If a document is unpublished, it gets removed from search results. Otherwise, draft updates to a published document have no effect.

Globals

Globals are not currently supported for indexing.

Algolia search config

The internal Algolia client accepts all options. Beyond that, the rest of the setup for a typical Algolia configuration is outside the scope of the plugin (setting search attributes and facets, etc).

Contributing

After cloning the repo and installing dependencies, run pnpm exec simple-git-hooks to setup automatic pre-commit linting.

Similar plugins