Search code examples
javascriptreactjsgatsby

How to use Icons like Font Awesome in Gatsby


I want to use Font Awesome Icons in my Gatsby project. I would love to include font awesome with a CDN.

Just including it in a script tag doesn't work. I think I need to import it with import ... from '../fontawesome.css' but i am not able to get this working and also wanted to use a cdn for that. Or do I need to parse it with a css library for gatsby?

Please give me advice or hints how to do it.


Solution

  • For anyone visiting this page in late 2018+, I would highly recommend using react-icons.

    import { FaBeer } from 'react-icons/fa';
    
    class Question extends React.Component {
        render() {
            return <h3> Lets go for a <FaBeer />? </h3>
        }
    }