How to load SVG as an asset / URI

The only way I could find that works is the below library. Is there something I’m missing - an easy way to load an SVG from file?


This seems about as straightforward as it could be given the limitations, IMO. The issue (as I understand it) is that Image doesn’t support the .svg file type, so this library reads the SVG markup from the file and renders it using react-native-svg components. Heads up that, I think, as of SDK 33/34, you can use the base repo instead of the Expo branch, because Expo now requires you to import react-native-svg components directly from react-native-svg.

1 Like

Ah, ok, that’s good to know. Probably a good switch I feel like a lot of libraries were having issues with react-native-svg import issues. I was at least.

Anyway, so you’re saying this repo will work instead of the fork - GitHub - vault-development/react-native-svg-uri: Render SVG images in React Native from an URL or static file?

Since Expo isn’t going to be providing a first-class solution to SVG file imports (which makes sense), still think it may be nice to include a note about the suggested library in the docs. But anyway, thanks for the help!

I’m not 100% sure that react-native-svg-uri, but I would try it first if you’re on SDK 34. In fact, the other repo might not work at all on SDK 34, because the old expo-specific imports were removed entirely.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.