TypeScript

Start by installing the Jdenticon NPM package. It comes with up-to-date typings.

npm install jdenticon

Import the Jdenticon package where you want to use it.

import jdenticon = require("jdenticon");

Now you can use any of the API methods to generate an identicon.

// Alternative 1
import jdenticon = require("jdenticon");
const svgString = jdenticon.toSvg("value", 100);
console.log(svgString);

// Alternative 2
import { toSvg } from "jdenticon";
const svgString = toSvg("value", 100);
console.log(svgString);

Default import

If esModuleInterop is enabled you can also use the ES6 import syntax for importing Jdenticon.

import jdenticon from "jdenticon";
const svgString = jdenticon.toSvg("value", 100);
console.log(svgString);