If you are using vite & react , use vite-plugin-svgr.
Install plugin: yarn add -D vite-plugin-svgr
Add this in the plugins array of vite.config.ts plugins: [svgr()],
Import the svg in your component :import Logo from "./logo.svg?react";
keep in mind the ?react part.
Add this in your vite-env.d.ts to get rid of type error /// <reference types="vite-plugin-svgr/client" />
Refer this link for more information: http://github.com/pd4d10/vite-plugin-svgr?tab=readme-ov-file#usage