Installation

Install the package

pnpm add svgin-react
pnpm add svgin-react

Sanitization dependencies

dompurify and jsdom are peer dependencies, not bundled. Install dompurify for the client sanitizer, and both for the server one (jsdom builds the DOM DOMPurify sanitizes against, since there is no browser DOM on the server).

pnpm add dompurify jsdom
pnpm add dompurify jsdom

Import paths

Pick the entry point that matches where a component actually runs and what it needs, rather than importing from svgin-react everywhere. Full reasoning in the API reference.

Entry pointExportsNotes
svgin-reactSvgInResolves to the server or client component depending on where it is imported.
svgin-react/clientSvgIn, SvgInProviderForced client.
svgin-react/serverSvgInForced server.
svgin-react/corepreloadSvg, clearSvgCache, hasCachedSvgNo React component, works in either environment.
svgin-react/suspenseSvgInSuspenseOwn entry point so it costs nothing unless you use it.
svgin-react/shadowSvgInShadowOwn entry point so it costs nothing unless you use it.
svgin-react/allEvery client + core exportOne import, larger bundle - for when you would rather not choose.