1---
2title: Use SVGs
3description: Learn how to create and use SVGs in an Expo project.
4---
5
6import SnackEmbed from '~/components/plugins/SnackEmbed';
7import { Terminal } from '~/ui/components/Snippet';
8
9SVGs (Scalable Vector Graphics) are a great way to present icons and other visual elements in a flexible, crisp, and performant way. Using SVGs on the web is straightforward since we can copy an SVG and place it inline in an HTML file. This works because browsers understand how to parse and present SVGs. Expo does not understand how to parse and present SVG out of the box on Android and iOS, so we'll need to use a React Native package and an SVG converter to do so.
10
11Let's go over the whole process of creating an SVG to presenting it in an Expo project.
12
13## Exporting an SVG
14
15Once we have a vector created inside a design program, like Figma, Illustrator, or Sketch, find the "export" menu and specify "SVG" as the export type. This will create an SVG file we can view in a code editor. Alternatively, these programs often allow right-clicking on an element, then copying it as an SVG.
16
17## Converting SVG files using a Babel transformer
18
19[React Native SVG transformer](https://github.com/kristerkari/react-native-svg-transformer) allows compile-time transformation to make SVG files compatible with React.
20
21Follow the installation steps to configure your Expo project to use this workflow. After your project is properly configured, you'll be able to use your local SVG files like this:
22
23```javascript
24import Logo from './assets/logo.svg';
25
26<Logo width={120} height={40} />;
27```
28
29## Converting individual SVG files for React Native
30
31Alternatively, [React-SVGR](https://react-svgr.com/playground/?native=true) is a great tool to convert individual SVG files. It takes an SVG as input then can transform it into another format, including a format that works with React.
32
33Paste the SVG contents from the exported SVG file into [React-SVGR](https://react-svgr.com/playground/?native=true) and make sure the "native" checkbox is ticked. It will provide output that we can copy and paste into our project.
34
35To automate this process, React-SVGR also [provides a CLI](https://react-svgr.com/docs/cli/) that could allow us to put regular SVGs in our project, then run a script that would convert them into React components automatically. If you have many icons, or a team of developers working on your project, it's definitely worth the time to set up process like this.
36
37## Including the SVG in our project
38
39Once we have a compatible SVG, we'll need to add [react-native-svg](https://github.com/react-native-svg/react-native-svg) to our project. We can do so with:
40
41<Terminal cmd={['$ npx expo install react-native-svg']} />
42
43Then we can add code like the following to our project:
44
45<SnackEmbed snackId="@jonsamp/react-native-svg-example" preview platform="web" />
46
47You can learn more about SVG with our [API Reference document on SVG](/versions/latest/sdk/svg/).
48