You have a folder of SVG icons from a designer, an icon set, or an old project. You want them as React components: <SearchIcon /> , <CloseIcon /> , each taking a className , a size , maybe a title . The usual answer is "add SVGR to your bundler." That works, but sometimes you can't or don't want to touch the build. Maybe it's a locked-down framework config, a design-system package that ships plain .js , or you just want readable component files in the repo that anyone can open and edit.
This post walks through a plain Node script that converts a directory of .svg files into .jsx components. There's no webpack loader or Vite plugin, and the only runtime dependency is React.
What actually changes between SVG and JSX
An SVG file is XML, and JSX is close to it, but not the same. A converter has to handle these differences:
Hyphenated attributes become camelCase.β¦