React utility that automatically rewrites SVG element IDs (id, xlinkHref, url(#...)) to unique, collision-free identifiers like ___SVG_ID__N__M___. This solves the problem of duplicate IDs when multiple SVGs processed by SVGO are used on the same page. Version 1.3.3 is the latest stable release (last published March 2020). The library ships with TypeScript types and has a peer dependency on React ^16.6.3. It is lightweight and specifically designed for React, unlike generic SVG ID deduplication tools.
npm install react-svg-unique-idVerified import paths — ran on the pinned version, not inferred.
Wraps an SVG in SVGUniqueID to ensure all id attributes and url(#...) references are made unique to avoid collisions when multiple SVGs with the same ids are rendered.
Ensure SVGs are inline (rendered as React elements) for id rewriting to apply.
Upgrade React to at least 16.6.3 or use a different approach for older React.
Do not rely on external references to ids inside SVGUniqueID; consider using a different id scheme or avoid wrapping if external references are needed.
Manually ensure that any CSS inside the SVG that references ids uses the new generated ids, or avoid inline styles.
Ensure SVGUniqueID wraps a single SVG element, not an array or fragment.
Run 'npm install react-svg-unique-id' and use correct import: import { SVGUniqueID } from 'react-svg-unique-id'Replace xlinkHref="#id" with href="#id" in <use> elements.
No dependency data recorded yet.