The new Cosmic dashboard is here!
Test drive it now →

QuickStart a Gatsby Application Using a Headless CMS API

Community Articles
Community Articles QuickStart a Gatsby Application Using a Headless CMS API

Using a headless CMS API has many advantages, namely time and ease of getting your application up and running while giving your cross-functional team the tools they need to get their job done. Cosmic enables content managers and developers to work better together. By providing an intuitive Admin Dashboard, powerful APIs, and flexible user roles, applications are built faster, more light-weight, and your whole team ends up saving time in the process. Developers can build applications using their favorite frameworks and programming languages, knowing they can integrate with any third-party APIs, databases or Static Site Generators. 

A Static Site Generator (SSG) that has broken onto the playing field in a major way is Gatsby. Gatsby lets you build blazing-fast sites with your data, whatever the source. Gatsby loads only the critical HTML, CSS, data, and JavaScript so your site loads as fast as possible. Once loaded, Gatsby prefetches resources for other pages so clicking around the site feels incredibly fast. 



Cosmic recently rolled out its Gatsby Source Plugin and its Gatsby Starter. The source plugin allows developers to easily fetch data into Gatsby from Cosmic, and the Starter App lets you get a Gatsby app up and running, connected to Cosmic for dynamic content changes in mere seconds. šŸ˜Ž  In this tutorial we'll quickstart a Gatsby application using the Cosmic headless CMS API.

TL;DR:

Gatsby Starter
Developer Docs
Gatsby Knowledge Base 


QuickStart a Gatsby App using a Headless CMS API

Cosmic is an example of a robust headless CMS and API that's promoting collaboration on cross-functional teams to build apps faster. Get started building Cosmic-powered apps in seconds šŸš€ We have Node.js, React, Vue, Gatsby and Serverless Starters to help you get your project started quickly.


šŸ› ļø Installation

Install via the Cosmic CLI:


I set up an example Bucket for this blog:


Run cosmic -h for a list of all commands. Run cosmic [command] -h for details on options for a specific command. You're now up and running with a Gatsby Starter that can be managed entirely from your Cosmic Bucket Dashboard and Command Line Terminal tool of choice. 

Conclusion

When ditching the installed content management system and going API-first isn't quick enough, check out the Starter Apps from Cosmic to get a project up and running in seconds. Cosmic integrates easily with Gatsby for an automated build process that allows you to maintain zippy static speed with dynamic content changes. šŸ”„

If you have any comments or questions about building React apps with Cosmic, reach out to us on Twitter and join the conversation on Slack.

You may also like


Cosmic provides tools and resources to create your own unique content publishing workflow that satisfies your team's needs. In this tutorial I'll demonstrate setting up a simple workflow for an Editor and Contributor team that needs to manage content in a draft, review and publish process.
Why should you migrate your CMS? What's the big deal about Cosmic? This article should answer some questions you have about cosmicJS and what the pros and cons are of using an API-driven Content Management System
In this article Iā€™m going demonstrate how to add new form submissions to Hubspot when you Publish Objects in your Cosmic Bucket.
Tony Spiro, co-founder and CEO of Cosmic, presented "Building for Team Success with Content-Powered Apps" to illustrate the build vs. buy concept of software development in the API-first microservices movement. The full video is embedded below and runs approximately 45 minutes.
Cosmic makes it easy to manage content for your Vue.js applications. In this blog we'll quickstart a Vue.js RPG Adventure Game using the Cosmic CLI. Our game, "Enter The Cosmos", is a turn-based, RPG style game built using Vue.js, Node.js and Cosmic.
Thank you to everyone who joined us for our Halloween edition of our Wednesday Webinar series. In this presentation, we discussed making localization for websites less spooky using Gatsby and Cosmic.

Get started with Cosmic

Personal projects are free. Scale up as you grow.
Start building Talk to sales