Cosmic JS Blog Stay tuned for community news, company announcements and updates from the Cosmic JS team.

Language Agnostic Content Management With Cosmic JS

If you’re a developer and need to open up a new blog for yourself or a client, the idea of using WordPress probably makes you cringe.

64.5% of developers surveyed on StackOverflow stated that WordPress was one of their most dreaded platforms to work with.

The dread makes sense. You can’t hand code an entire blog if you use WordPress for your content management system (CMS). You have to work within the WordPress stack and then use plugins for the extra pieces you need. This is antithetical to most people who write plain code.

What you probably want is a system that lets you input your content, store your content, and fetch it in a manner that is straightforward and easy. If you can input your content in a WYSIWYG dashboard even better¹.

While looking for something that did this I stumbled on Cosmic JS. It turns out that Cosmic is exactly that, a programming language agnostic CMS. You can write your blog in whatever language you want for whatever platform you want.

You put your content in and it gives you simple API endpoints to retrieve it from. One get request and your work is returned to you in a JSON object.

Here’s how you can setup a CMS for your blog in no time flat…

Once you’ve created and logged into your account go ahead and create a new bucket. Buckets are exactly what they sound like. A container that holds objects. The objects could all be of the same type or they could be different.

Once you’ve created your bucket and you click on it you’ll notice a new menu on the sidebar. One of the options will be Add Object Type.

This is how we add a new type of object to our bucket. We’re going to be creating a Blog Post type object that will hold all of the content and metadata associated with each of our blog posts.

Once you’ve clicked Add Object Type and input a name into the name field note that the name has been mapped to an API endpoint. These endpoints, which you’ll find on every single object page in Cosmic, are the beauty to the system. This endpoint will return all of your Blog Post type objects.

Make a simple get request to it and you’ll receive a JSON object that contains each of your posts and the metadata associated with each one. If you have 5 posts, it will return 5. 100, it will return 100.

At it’s base every object in a bucket automatically includes a title field and an HTML input field. So right off the bat without adding any metafields you have the basic components of a blog post.

To show more of the power Cosmic has lets add a cover image and description field to our Blog Object. While you’re creating your new object, clicking on the Metafields Template tab at the top will bring up the UI to add these.

Now that we have our object type created we can create an actual object of that type.

Once you’ve clicked Blog Posts you can +Add Blog Post. Inside you’ll see the structure of the Blog Post type object that we specified. All we need to do now is fill in each field with the content that we want.

Once you’ve input your content and hit publish or save draft² you’ll be given an API endpoint. To retrieve just this post you would send a get request to that endpoint and you’ll get your entire pre-formatted post back in JSON form.

Notice our added metafields and, most importantly, that our content remains in it’s HTML format.

That’s all there is to it. All you have to do is build out the front-end of your blog in whatever specs you like, write some content, retrieve your content, and then inject that content wherever you need to.

¹Though you could opt to build out or implement your own editor. Cosmic’s API does include tools for that.

²The API endpoint will not be live if you save as a draft.

Developer, entrepreneur, and writer. You can find me over at where I write about current projects, tech, code, and sometimes life itself.

Article originally appears on

You may also like

In an effort to make it easier to create content-ready applications as well as manage content, you can now install and deploy applications using Cosmic JS.  It's the fastest and easiest way to go from 0 to content-ready web app (about 2 minutes!) without any server or configuration hassle.  It's really cool and only requires a few steps:

1. Sign in to your Cosmic JS account
2. Choose a bucket then navigate on the left sidenav to Settings > Apps
3. Select your app and click "Install"
4. Go to Settings > Deploy Web App and click "Deploy Web App"

In about 2 minutes your application will be deployed and connected to your Cosmic JS bucket.  Add and edit content easily and review from the deployed location.  Choose from one of the provided apps or add the link to the public git repo to clone your own app into deployment.

You can deploy your applications from any GitHub, BitBucket or any other public repo. Your application will be deployed to it's own isolated Docker container using Dokku, a Docker-powered mini-Heroku. This means that you can build your app in any language and easily deploy it from Cosmic JS!  You can find out more about how to make apps Dokku compatible by reading Heroku documentation

If you would like to contribute apps to be available on Cosmic JS, please contact  Happy building!

At the request of the Cosmic JS Community, new Multi-Bucket Pricing Tiers are now Available for teams. Introducing, Cosmic Clusters. 

In this Developer Spotlight we sit down with Ben Packer, a web developer who's writing code for a cause.

Rapid prototyping is the process of quickly building a scale model for display to a client or partner, knowing that the prototype can be changed at a moment's notice. For a builder this could be an actual model, for a product it could be a mold model, and for an agency or development shop it could be a number of things. Many agencies will build rapid prototypes not just to display creative, websites & apps for clients, but to win the business in the first place by demonstrating a certain level of commitment to and understanding of the product or service at hand. Rapid prototyping allows the development team to participate in a faster feedback loop to get the best possible product while allowing the client to participate in the process. The constraints are usually time, money & technology infrastructure in terms of how that rapid prototype can be reviewed, and where.

In last week's article, Tony told us about the ingredients in The Cosmic Stack, why it is so powerful and what its benefits are. Now that we've seen what The Cosmic Stack looks like, let's look at how we can customize our use of it. 

From a high level, you have three basic ways to use The Cosmic Stack. You have flexibility to use just the CMS API, the CMS API and your own app hosted on the Cosmic app server, or the CMS API with a pre-built content-ready app hosted on the Cosmic App Server.

We sat down with Abe Hendricks for our latest installment of the Cosmic JS Developer Spotlight Series.