Algolia's latest articles, right in your inbox.

Pick up the topics you are the most interested in, we take care of the rest!

Thank you for subscribing, stay tuned!

Loading amazing content . . .

Share on facebookShare on linkedinShare on twitterShare by email

Early February, we released the Algolia API Client JavaScript v4, our most powerful JavaScript client ever. It’s faster, smaller, and more flexible, and provides full support for our Common API Client specifications. Significantly, it includes previously unavailable methods like zero-downtime reindexing, cross-account operations, and many other complex operations.

The good news is that it involves only minimal changes to the API, so updating should take less than ten minutes: Upgrade Guide.

In this article, we’ll highlight some of the main advances in this brand new version.

Reduced file size

Our new client comes packed with new features; yet, despite these additions, it’s actually smaller compared to v3:

  • The lite version is 4.27 kb gzipped on v4, down from 13.21 kb on v3.
  • The default version is 7.44 kb gzipped on v4, down from 19.35 kb on v3.

That amounts to a combined 64% size decrease compared to the previous version. With this decrease, your page loads faster.

Zero dependencies

Also, we’ve reduced the number of dependencies from 15 to 0. Yes, that’s right – 0 dependencies. So we no longer take the risk of receiving third-party updates that might break the client.

Taking DX one step further

To provide the best developer experience, we’ve added a bunch of new helpers that aren’t just a simple mapping to API endpoints. Users are now able to `replaceAllObjects` with zero downtime, or `copyIndex` between apps, and many other such multi-task operations! Here are some examples:

State of the art JavaScript

For optimal developer experience and type safety, the new client is fully written in TypeScript. Thanks to this, the developer will be able to leverage optional static typing and type inference out of the box.

Redesigned architecture

Just like v3, we ship with two versions: lite and default – these are predefined versions that help developers get started quickly using the traditional: “algoliasearch(appId,apiKey)”.

Now, thanks to a brand new architecture, you can build your own version of the client, adapted to your needs. Here is an example:

With this approach, developers can inject their own requester and logger, as well as their own cache implementations. Good news is that, even if you inject your concrete implementations, everything still runs under our retry strategy.

We believe this modularity helps developers meet the demands of more advanced use cases.

And more!

The Algolia API Client JavaScript is 100% open source, so feel free to dig through the source code to see exactly how it works. Dig right in! Visit our documentation.

See something that needs to be improved? Just send us a pull request on GitHub.  Thanks! And we hope you enjoy this new release! 🎉

About the author

Loading amazing content . . .