Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

89
Views
Best way to convert SVG to JSX directly inside of a common React component library

I am trying to figure out the best way to import SVG images directly as JSX components inside my React common component library. By "common component library" I mean a separate package that contains common components that a variety of web apps within my organization can use.

Here is an example of a monorepo setup with both a web app (apps/web) and a common ui library (packages/my-core) that uses a library called Turborepo: https://github.com/MahdiTa97/turborepo-boilerplate/blob/main/package.json

Typically in a NextJS or Create React App project I would take advantage of the SVGR webpack plugin and write an import statement like this:

import { ReactComponent as ExampleIcon } from 'common-ui-library/images/icon.svg'

and would use ExampleIcon like any ordinary React component.


Things are a little bit different in the context of a common UI library. Webpack isn't being used in the library and to my knowledge everything contained within this "common ui library" needs to be a proper module.

The last thing I want to do is to set up a separate "images" package that uses Rollup (or similar) and some sort of watcher that runs any time I am developing.

I am really happy with how this particular setup allows me to develop without needing to run a separate watcher process for the common ui library.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

here is the package: svg-to-jsx

you can try with this. npm i svg-to-jsx

Thanks.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!