Server Side

Config

Meilisearch Server Side

🚨🚨 Breaking CHANGE 🚨🚨

From v1.4.0 and above, you access to Meilisearch with $meilisearch(event)

$meilisearch(event)

Due about a change build process frm nitro, we need to pass the event to the function.


Configuration

You can to manage documents, indexes or preferences from Nuxt server side. To do so, first enable it

nuxt.config.ts
meilisearch: {
  ...
  serverSideUsage: true, // default false
  adminApiKey: '<your_secret_key>',
  ...
}
You need to provide API KEY with ADMIN ACCESS

Usage

Now you can use the $meilisearch(event) instance from your server side code.

Full exemple:

my-endpoint.ts

export default defineEventHandler(async (event) => {

  // read from body
  const body = await readBody(event)

  // Meiliseach is available with $meilisearch
  const meilisearchResponse = $meilisearch(event).index('books').addDocuments(body)

  return meilisearchResponse

})

Typescript

$meilisearch is full typed so you can enjoy the full power of typescript, autocomplete and intellisense.