Quick Bucket setup code sample using the Cosmic NPM module

Community Articles
Community Articles Quick Bucket setup code sample using the Cosmic NPM module

This is a quick example to show some of the powerful things you can do with the Cosmic NPM Module.  This script adds a Bucket to your Cosmic account, adds a Pages Object Type and adds a few Pages.

To run the code:

1. Copy the bucketSetupExample.js file locally into a new folder.
2. cd your-folder; npm i cosmicjs
3. Add your secret authentication token to the code found in Account Settings > Authentication
4. node bucketSetupExample.js

You may also like


In this tutorial, Cosmic co-founder Tony Spiro takes you on a tour of Cosmic Webhooks. Learn how webhooks work, see how to easily install integrations with Slack, auto-deploy websites to Netlify, and get an intro to Cosmic Functions.
A website boilerplate satisfies some common website requirements including dynamic pages, blog articles, author management, SEO ability, contact form and website search.
Grab and save content from any website to your Cosmic Bucket.
5 Website Boilerplates: React, Node.js, Vue, Nuxt.js and Next.js
Cosmic Extensions make it possible to extend the functionality of Cosmic for both the developer and editor. A recent example built by the Cosmic Community is the Google Analytics Extension, which allows team members to easily see analytics insights directly in their Cosmic Bucket.
In this tutorial I'm going to show you how to build a component-based website using Cosmic.

Get Started with Cosmic

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