Cosmicjs Node screenshot

Cosmicjs Node

Author Avatar Theme by Cosmicjs
Updated: 17 Jun 2023
276 Stars

*API v2 JavaScript client for Cosmic. See important message in README

Categories

Overview:

The Cosmic NPM module is a content management system (CMS) that allows users to create and deliver content to any website or application. It provides a web dashboard for content creation and an API toolkit for content delivery. The module is designed to save time and launch projects faster by providing all the necessary features out of the box.

Features:

  • Powerful content modeling: Users can build nearly any type of content model using the admin dashboard.
  • Flexible queries: The module allows for flexible queries to retrieve specific content.
  • Customized API response: Users can customize the API response according to their needs.
  • Localization: The module supports localization, allowing for localized content.
  • Image optimization: Images can be optimized to improve performance.

Installation:

To use the Cosmic NPM module, follow these steps:

  1. Go to https://www.cosmicjs.com and create a free account.
  2. Set up a project either from scratch or by starting with a pre-built template.
  3. Install the Cosmic NPM module by running the following command:
npm install cosmicjs
  1. Import Cosmic into your app:
import Cosmic from 'cosmicjs'
  1. In your Cosmic admin dashboard, go to Your Bucket > Settings > API Access and obtain your Bucket slug and read key.
  2. Set the variables in your app to connect to your Bucket:
const API_BUCKET_SLUG = 'your-bucket-slug';
const API_READ_KEY = 'your-read-key';

Cosmic.getObjectType({
  bucket_slug: API_BUCKET_SLUG,
  read_key: API_READ_KEY,
})
  1. To deliver content to your app, use the objects.find method. For example, to get multiple objects, use the following code:
Cosmic.objects.find({
  bucket_slug: API_BUCKET_SLUG,
  read_key: API_READ_KEY,
  type: 'your-object-type',
})
  1. For more advanced usage, refer to the full documentation.

Summary:

The Cosmic NPM module is a powerful CMS that simplifies content management by providing a web dashboard and an API toolkit. It offers features such as powerful content modeling, flexible queries, customized API responses, localization, and image optimization. By using this module, users can save time and launch their content-powered apps faster.