nuxt-modules / algolia

🔎 Algolia module for Nuxt
https://algolia.nuxtjs.org/
MIT License
193 stars 35 forks source link

useAlgoliaRecommend for SSR #211

Open MickL opened 1 week ago

MickL commented 1 week ago

It seems like useAlgoliaRecommend() is not working on SSR:

<script setup lang="ts">
    const { result, get } = useAlgoliaRecommend<AlgoliaProduct>();
    await get({ ... });
<script>

<template>
   {{ result }}
</template>

I get the error:

(void 0) is not a constructor
    at @algolia/recommend/dist/recommend.esm.browser:226:31
    at new Promise (<anonymous>)

[nuxt] Failed to stringify dev server logs. Received DevalueError: Cannot stringify arbitrary non-POJOs. You can define your own reducer/reviver for rich types following the instructions in https://nuxt.com/docs/api/composables/use-nuxt-app#payload.

For useAlgoliaSearch there is useAlgoliaSearchAsync. Can we have the same for useAlgoliaRecommend()?

Motivation: For SEO purposes I want to display the recommendations right away and not lazy in the browser. For example by use of Sistrix I realized that all my products only have exactly one link referencing it (from the product overview).

Baroshem commented 1 week ago

Hey @MickL Thanks for creating this issue!

I can totally see the use case for it!

Would you be interested in creating a Proof of Concept PR with it? :)

MickL commented 4 days ago

@Baroshem Unfortunately I dont have the time and the knowledge for this. Btw. I already made a PR to fix #201 in july but it never got merged.