Next.js Discord

Discord Forum

Importing SVG files as raw HTML

Unanswered
Short mackerel posted this in #help-forum
Open in Discord
Short mackerelOP
Inside a Server Component I am importing a SVG via "import svg from '../public/test.svg'". What I want is the raw <svg> html, because I am doing some calculation on the server with the nodes. But when I console.log(svg) I get an object containing a src ('/_next/static/media/test.bf1af21.svg'), width and height.
Now I could get the raw html code via fetching that src. But to me it seems like an unnecessary step to access what I want (also adding more vercel credits as necessary?). Is there a way to directly access the html of the svg without the intermediate step of fetching it?

4 Replies