DEV Community

Luisa Novaes
Luisa Novaes

Posted on

Do I store image assets in public or src in ReactJS ?

public: anything that is not used by your app when it compiles

src: anything that is used when the app is compiled

So for example if you use an image inside a component, it should be in the src folder but if you have an image outside the app (i.e. favicon) it should be in public.

Matt Saunders
from Stackoverflow

Example

At Component.js

import logo from "../assets/logo.svg"

const Component = () => {
   return (
     <div>
        <img src={logo} alt="" />
     </div>
   )
}

export default Component;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)