How to build a blog with Cosmic and React

Community Articles
Community Articles How to build a blog with Cosmic and React

TL;DR

Build a Cosmic React application by creating a new Cosmic App and cloning a repository.


Introduction

A CMS API gives more power to content creators and developers to build their type of front end web applications. React will continue to receive lots of attention in 2018 as a top Javascript framework.  Cosmic gives front end developers more time to build client applications and spend less time setting up API's or Databases. A MongoDB instance would be one more part to what is a simple process. There is no need  to update a static file, log into a server. The Cosmic content editor powers your application.


Cosmic provides a platform that lets developers focus on the code, and design. This means more time pushing code and less time thinking.  


Build a blog with Cosmic

Logging into to your Cosmic account is easy, sign in with Github! Check out the Cosmic Apps and find Simple React Blog. Click on the install Free button and build your new blog application. 


Create your first post

On app install, you will be directed to your new app dashboard. In this example, there are 4 Objects - Posts, Author, Categories, and Globals. Your blog content lives in the Posts Object, so let's create a new blog post! Click on the Posts object, in the left-side navigation bar, and select Add Post



Create a blog post and be sure to inspect the functionality of the editor. Insert an image, write some code, add a link, and of course a 😀 .  Content creators are not limited to the type of content they can create. 

To create a new author, check out Author and select add author.


  


Let's select an image to go along with our blog post. 



Hit the publish and push our blog post dynamically to our application. Notice the option of switching between developer and editor roles. 

Cosmic Credentials

In the left-side navigation bar select Settings and Basic Settings. Create a new Read/Write Access key by selecting Generate new key for both. 

Let's keep this tap open for the remainder of the tutorial.

 




Deploy Your Web App

You can deploy your web app from from Cosmic Dashboard with the Git repo Url. Click settings -> Deploy Web App. Make sure your Git Repo URL is set to https://github.com/cosmicjs/react-blog



Another important step is to set your environment variables. Copy and paste the API Read Access Key, API Write Access Key, and Bucket Slug into your Set Environment Variables  tab from the Cosmic Credentials section.



Press Deploy to the Web and visit your new blog!

Development Mode

Prerequisites

  • Node 
  • NPM

Terminal Commands

 Start the application

npm start

View your Cosmic Blog!

Building Blog applications with Cosmic is this simple. Be sure to check out the OG GraqhQL and React version of our Blog App on Github. If you would like to see other demos and source code, check out the apps page.

I hope you enjoyed this tutorial, if you have any questions reach out to us on Twitter and join our community on Slack.

You may also like


In this walkthrough, I'm going to show you how I build a blog application in Go Lang. I'll also talk about styling it using Tailwind CSS and lastly, I'll show you how you can utilize GitHub Actions to deploy your Go-based applications to Heroku.
In basically one Saturday, I was able to move from a confining WordPress instance for my blog to a blazing fast new blog fueled by Cosmic. This flexibility is going to enable me to improve my blog how I want to, serve my content how I want to, design my workflow how I want to.
Every blog needs a solid Content Management System (CMS). This allows content owners to control their content without having to hire a developer to make every single change to their site. Cosmic is a great choice for a CMS. In this how-to article, we’ll connect a React/Next.js app to Cosmic .
Cosmic has powerful content modeling and delivery tools to help you build apps faster, together. Cosmic lets you manage all your content, data and files and is unopionated as to the format of content you're uploading. The Cosmic Editor allows you to upload rich media such as video, images and
This time, we will add filtering functionality to showcase the Cosmic Advanced Queries feature. Our data will be stored and served by Cosmic and we will use Angular for our Front-End.
Next.js is a React framework for building hybrid applications. It's flexible, extensible, and works great with any data provider. In this tutorial, we'll show how to get started with Cosmic CMS and Next.js.

Get Started with Cosmic

Build personal projects for free. Add your team at unbeatable prices.
Start Building Talk to Sales