Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Barebones starter for a headless Craft CMS & Gatsby configuration.
Gatsby Craftcms Barebones is a boilerplate project that pairs Gatsby with a headless Craft CMS backend, exposing content through the CraftQL GraphQL plugin.
Gatsby Craftcms Barebones is a starter template for building a headless CMS site with Gatsby as the front end and Craft CMS as the backend. It walks through installing a new Gatsby project, adding Craft CMS via Composer into a craft subdirectory, setting up MySQL, linking Laravel Valet, creating a Posts section, and installing the CraftQL plugin to serve content over GraphQL. The final setup lets developers query Craft entries from Gatsby using gatsby-source-graphql.
craft.test/api.gatsby-source-graphql to gatsby-config.js, with a field name of craft and a type name of Craft.dotenv to load the CraftQL API token from a .env.development file created at the project root.index.twig file that loops through all entries in the Posts section and displays each title and post content.valet start and valet link) and initializing Craft through the browser at craft.test/index.php?p=admin/install.craft.test/api to fetch entry titles and post content, verifiable with GraphiQL or curl.The setup follows a specific sequence: create a Gatsby project with gatsby new, install Craft CMS with composer create-project craftcms/craft, start a MySQL database and configure the .env file, link the directory with Valet, install Craft through the browser, create a Posts section and entries, enable the CraftQL plugin and generate a token, then configure gatsby-source-graphql with that token in the environment file. The result is a Gatsby site that can fetch Craft content through GraphQL.
You need PHP, Composer, Laravel Valet, MySQL, and the Gatsby CLI installed globally. The README directs users to the Valet documentation and the MySQL download page for setup.
No, it is a barebones configuration. The Gatsby project is created with gatsby new, and the starter only adds the source plugin and environment setup. The included Twig template is a minimal display example, not a full theme.
It is designed for local development and integration testing. The steps focus on getting a working connection between Craft CMS and Gatsby, not on deployment, styling, or performance optimization.
The token is generated in the CraftQL plugin settings and placed in a .env.development file at the project root. The gatsby-config.js file reads it with dotenv and sends it as an Authorization header with a bearer prefix.
