SSR result packing and hydration
Typically SSR frameworks (Next, Nuxt, Remix, etc) will transfer data from backend to frontend in JSON format. Passing KlevuFetch result object to frontend won't work as it is filled with functions that help the usage of results.
There is an option to just pass raw JSON with result.apiResponse and build your logic on top of that.
If you wish to keep using helper functions provided in results you can use KlevuPackFetchResult() function to pack result like:
And then you can hydrate it in frontend with KlevuHydratePackedFetchResult() function.
It's important to note that the second parameter of KlevuHydratePackedFetchResult() has to be the same as in backend call. You can create query functions in a separate file that can be called both in frontend and backend. For example:
Example of using this technique can be found from Shopify Hydrogen example in here.