Installation

Install the package

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

Import paths

Pick the entry point that matches where a component actually runs, rather than importing from svgin-react everywhere:

  • svgin-react/client: SvgIn, SvgInSuspense, SvgInProvider - browser only.
  • svgin-react/server: SvgIn - the async React Server Component version.
  • svgin-react/core: preloadSvg - works in either environment.