How to include external javascript library in PreactJS?

Viewed 2141

I'm currently one small project based on preactJS with algolia? I found that there is algolia component for reactjs but unfortunately, no algolia component for preactjs. That's why my problem is how can I include algolia javascript file into preactjs?

<script src="https://cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.js"></script>
4 Answers

You can install the package algoliasearch (if package is not correct, just search the desired package at https://npmjs.com)

Now you can do npm install algoliasearch --save at your root level where package.json is there and use it in your module like following -

import algolia from 'algolia';

And then use its methods in your code.

Related