algoliasearch-client-javascript icon indicating copy to clipboard operation
algoliasearch-client-javascript copied to clipboard

[bug]: Lastest version of algoliasearch doesn't function on React Native apps

Open wildseansy opened this issue 7 months ago • 4 comments

Description

When I upgrade algoliasearch in my app from 4.24.0 to 5.23.4, both the lite client and the normal client throw exceptions on initialization. Does algolia 5.x not work with React Native?

It seems to be the case:

Lite version

  import { liteClient } from "algoliasearch/lite";
  const client =  liteClient(ALGOLIA_CONFIG.appId, algoliaToken);

Throws:

 TypeError: 0, _clientCommon.createNullLogger is not a function (it is undefined) (browser.js 265:29)

Full version

  import { algoliasearch } from "algoliasearch";
  const client = algoliasearch(ALGOLIA_CONFIG.appId, algoliaToken);

In this case, algoliasearch isn't even exported correctly at runtime (its types say it's available via ESM).

It Throws:

TypeError: 0, _algoliasearch.algoliasearch is not a function (it is undefined)

Ideally, I would like to use the non-lite version because we want to log engagement events back to algolia, and I don't think that is supported in the lite version. Please advise if this is a bug or if this sdk version isn't available for React Native

Client

Search

Version

5.23.4, 5.24.0

wildseansy avatar Apr 26 '25 22:04 wildseansy

I upgraded to 5.24.0 (it's on npm but not a release on this repo?) and this fixed the problem.

aaron-adimverse avatar May 01 '25 18:05 aaron-adimverse

I upgraded to 5.24.0 (it's on npm but not a release on this repo?) and this fixed the problem.

I spoke too soon. Doing this upgrade fixed the problem when running a build from my machine, but once deployed it does not work. For reference I'm using Nextjs 15 and building a web app. I get the exact same error though.

aaron-adimverse avatar May 01 '25 22:05 aaron-adimverse

I switched to using the search client directly instead and it's working as expected.

import { searchClient } from '@algolia/client-search'

aaron-adimverse avatar May 02 '25 16:05 aaron-adimverse

@aaron-adimverse thanks for the recommendation, on React Native however, it still has the same issue regarding createNullLogger Image

wildseansy avatar May 03 '25 22:05 wildseansy