Eventhandler after hits are rendered

How can i call a function after the hits are rendered?

I want to add DFP within my hits, but then i have to call the the DFP refresh when the div is visible in the DOM.
With the searchFunction result events this is too early since the DOM isn’t changed.

A finished/rendered event would be helpful i think, now there is only a render event but this is actually a “before” render.

Hi @tsmits,

Thanks for contacting Algolia.

From your question it appears that you have a good understanding of Algolia and of our docs.

Indeed, the appropriate place to trigger a function after a request has been sent to Algolia is the render function you already noted:

const search = instantsearch({
  // ...

search.on('render', () => {
  // Do something on render

Docs: instantsearch | InstantSearch.js | Algolia

If you find that you have different needs, it may fall outside the scope of Algolia. I recommend using StackOverflow to tap the active Algolia-developer community.

Let us know how it goes!

Is something similar possible with VueInstantSearch?

Hi there,
It depends on what you want to do.
In general, you can create a custom component and put your logic in the watcher like this:


import { createWidgetMixin } from 'vue-instantsearch';
import { connectStats } from 'instantsearch.js/es/connectors';

export default {
  mixins: [
    createWidgetMixin({ connector: connectStats })
  watch: {
    state() {

Let me know how it works for you :slight_smile:

How Can I do this in React? Please help. Thanks.

Hi @sonali.batra, you should be able to use the onSearchStateChange prop.

hi. Can you please elaborate. Thanks a lot!