Create a Custom Hook for Site Metadata in Gatsby

InstructorSam Julien

Share this video with your friends

Send Tweet

Gatsby's useStaticQuery hook is really useful for getting site metadata from our Gatsby config into our components. In fact, it's so useful that we end up using it all over the place and duplicating a lot of code! Luckily, since useStaticQuery is just a React hook, we can use it to compose our own custom useSiteMetadata hook.