Jdenticon is a JavaScript library for generating unique, recognizable identicons, often used for user avatars or cryptographic hashing visualization. It supports rendering these icons into both HTML5 Canvas (raster) and SVG (vector) elements, providing flexibility for different display needs. The library offers distinct bundles for browser and Node.js environments, enabling client-side display or server-side image generation, including PNG outputs. The current stable version is 3.3.0. Release cadence is somewhat ad-hoc, with several minor releases per year addressing bugs, improving TypeScript support, and enhancing features. Key differentiators include its dual Canvas/SVG rendering capabilities, a wide range of configurable aesthetic properties (padding, saturation, hues), and a CLI tool. Since version 3.0.0, automatic icon rendering on page load requires explicit opt-in.
npm install jdenticonVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use Jdenticon to render icons on page load and dynamically create/update icons, accounting for v3.0.0 breaking changes.
Call `jdenticon.update()` after DOM content is loaded, or `import 'jdenticon/standalone'` instead of `jdenticon` if you prefer the old automatic rendering behavior.
If you relied on zero padding for `drawIcon`, explicitly pass `{ padding: 0 }` as part of the config object to the `drawIcon` method.Update your configuration to use the nested `saturation.color` and `saturation.grayscale` properties for finer control over saturation settings.
For browser-specific code: `import { update } from 'jdenticon/browser';`. For Node.js-specific code: `import { toPng } from 'jdenticon/node';`.Ensure you are on Jdenticon v3.0.1 or later. If issues persist, review your `tsconfig.json` `lib` array and `typeRoots`.
If using a module system, import named exports like `import { update } from 'jdenticon';`. If using a script tag and relying on auto-rendering, ensure you are importing `jdenticon/standalone` or explicitly call `update()`.Check your `node_modules` for `jdenticon`. If using a bundler with specific environment targets or Node16 module resolution, try `import 'jdenticon/browser'` or `import 'jdenticon/node'`.
Explicitly import `toPng` from the Node.js specific bundle: `import { toPng } from 'jdenticon/node';`.Ensure you are passing a valid canvas context or element from a library like `node-canvas` when calling `drawIcon` in a Node.js environment.
No dependency data recorded yet.