Add Contentful as a data source for Gatsby

InstructorKhaled Garbaya

Share this video with your friends

Send Tweet

In this lesson, you will learn how to set up your Gatsby project to use Contentful as a data source using the gatsby-source-contentful plugin.

Shripada Hebbar
Shripada Hebbar
~ 2 years ago

One question - is it ok to directly mention the access token inside the gatsby-config.js? Since you might commit this code and share it with others, this could be a security issue. Is it not there any support for environment vars or something in gatsby? Thanks a lot.

Frank Manno
Frank Manno
~ 2 years ago

One question - is it ok to directly mention the access token inside the gatsby-config.js? Since you might commit this code and share it with others, this could be a security issue. Is it not there any support for environment vars or something in gatsby? Thanks a lot.

My understanding is that it's a "read-only" token, so I'm guessing that's why it's okay to include it in the gatsby-config. I may be wrong, however.

Khaled Garbaya
Khaled Garbaya(instructor)
~ 2 years ago

Hi Shripada, That's a great question and a valid concern. as Frank mentioned the delivery token is read-only. But it is always best practice to include credentials in environment variables for extra security especially if your website is open source. For the purpose of this exercise, I decided to add the token directly in the gatsby-config for simplicity reasons.

Cheers, Khaled

Shripada Hebbar
Shripada Hebbar
~ 2 years ago

Thanks for responses. Frank, Khaled. I understand it is a tutorial and I think we need to warn someone who plans to copy this code as is into their production. I have seen people making this mistake especially when they are new to programming...

Alexander Lopez
Alexander Lopez
~ 2 years ago

Hi, one question, what’s in your cli, that shows like a ghost/autocomplete of what you’re typing?

Khaled Garbaya
Khaled Garbaya(instructor)
~ 2 years ago

Hi Alexander, I use zsh with a plugin called zsh-autosuggestions https://github.com/zsh-users/zsh-autosuggestions.