Nuclia JavaScript SDK guide
Installation
Vanilla JS
The Nuclia SDK is provided as a UMD module. It exposes a NucliaSDK
object, giving access to its different classes.
<html>
<script src="https://unpkg.com/rxjs@7.5.2/dist/bundles/rxjs.umd.min.js"></script>
<script src="https://unpkg.com/@nuclia/core@latest/umd/index.js"></script>
<script>
const nuclia = new NucliaSDK.Nuclia({
backend: 'https://nuclia.cloud/api',
zone: 'europe-1',
});
</script>
</html>
With a build tool
The Nuclia SDK is also provided as an ESM module that you can load as an NPM dependency in your project:
npm install @nuclia/core
Or:
yarn add @nuclia/core
Then you can import it into your JavaScript or TypeScript code:
import { Nuclia } from '@nuclia/core';
Or:
const Nuclia = require('@nuclia/sdk');
With NodeJS
This SDK can work in NodeJS by providing some polyfills for localStorage
and fetch
:
const { Nuclia } = require('@nuclia/core');
require('localstorage-polyfill');
require('isomorphic-unfetch');
const nuclia = new Nuclia({
backend: 'https://nuclia.cloud/api',
zone: 'europe-1',
knowledgeBox: '<YOUR-KB-ID>',
});