Setup a Gatsby Project to Use Recipes

Khaled Garbaya
InstructorKhaled Garbaya

Share this video with your friends

Send Tweet
Published 2 years ago
Updated 2 years ago

Gatsby Recipes are a new tool of the gatsby-cli which require the latest install of the package. You will need to install the cli with npm install -g gatsby-cli@latest

Gatsby Recipes allow you to add common functionality to your Gatsby site with none of the headache of dealing with all the various plugins that would are required.

In this lesson, you will see how easy it is to install and run Jest with an official Gatsby recipe. What used to be a multiple step process (including modifying babel configs) is now a simple install command away.

Khaled Garbaya: [0:00] I have here an existing Gatsby project. To use Gatsby recipes, I need to upgrade some dependencies. To do that, we need to run yarn upgrade --latest. We need also to install the latest Gatsby CLI. To test this, we need to run gatsby recipes, and we should be able to see all the lists of the official recipes.

[0:24] To use one of them, we just go through the list, and pick one and hit Enter. You can see here it's showing us some instructions and telling us to press Enter. Let's press Enter. First thing this recipe will do is to install the Jest dependency. Let's do that.

[0:44] Now it's telling us that the recipe will create an example file. Here, we can see what will change. Since this is a new file, it's all addition. Let's hit Enter. The last step is to add an npm script to our package.json. You can see here the new added one. We hit Enter. You can see here that the recipe is run.

[1:12] If we do npm test, you can see that Jest is running, and our project is configured to use Jest.