Installation
Install the package
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).
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 point | Exports | Notes |
|---|---|---|
| svgin-react | SvgIn | Resolves to the server or client component depending on where it is imported. |
| svgin-react/client | SvgIn, SvgInProvider | Forced client. |
| svgin-react/server | SvgIn | Forced server. |
| svgin-react/core | preloadSvg, clearSvgCache, hasCachedSvg | No React component, works in either environment. |
| svgin-react/suspense | SvgInSuspense | Own entry point so it costs nothing unless you use it. |
| svgin-react/shadow | SvgInShadow | Own entry point so it costs nothing unless you use it. |
| svgin-react/all | Every client + core export | One import, larger bundle - for when you would rather not choose. |