npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cosmicjs

v4.3.7

Published

The official client module for Cosmic. This module helps you easily add dynamic content to your website or application using the Cosmic headless CMS.

Downloads

3,543

Readme

Cosmic NPM module (dashboard v1)

IMPORTANT

This package connects to projects on the old Cosmic dashboard and API v2 only. To connect to projects on the new Cosmic dashboard and API v3 use the Cosmic JavaScript SDK.

Content management made simple, fast, and secure.

Cosmic is a headless CMS (content management system) that provides a web dashboard to create content and an API toolkit to deliver content to any website or application. Build nearly any type of content model using our admin dashboard then deliver your content powered by our reliable infrastructure and global CDN.

Save time and launch faster

Avoid the pain of building, configuring, and maintaining your own CMS infrastructure. Cosmic has all of the features you need out of the box optimized and ready. Plug into Cosmic, save time, and launch your content-powered apps faster.

Features include

🛠️  Powerful content modeling 🔍  Flexible queries ⚡  Customized API response 🌎  Localization 🎨  Image optimization …and more! See more features →

Get started

Start by going to https://www.cosmicjs.com, create your free account and set up a project. You can get started from scratch, or start with a pre-built template. Then follow the steps below to use this NPM package.

Install

Install the Cosmic NPM module:

pnpm install cosmicjs
# OR
yarn add cosmicjs
# OR
npm install cosmicjs

Import

Import Cosmic into your app:

const Cosmic = require("cosmicjs")
const api = Cosmic()

Connect

In your Cosmic admin dashboard go to Your Bucket > Settings > API Access and get your Bucket slug and read key then set the variables in your app to connect to your Bucket:

const bucket = api.bucket({
  slug: "YOUR_BUCKET_SLUG",
  read_key: "YOUR_BUCKET_READ_KEY",
})

Get content

Delivering content to your app is simple using the objects.find method.

Get multiple Objects

Use the objects.find method and set the type property to any Object Type slug. Additional options noted below.

const data = await bucket.objects.find({
  type: "products" // Object Type slug
})
.props("title,slug,metadata") // response properties
.limit(10) // number of Objects to be returned

Get single Object by slug

Use the objects.find method and set the slug property to any Object slug.

const data = await bucket.objects.find({
  type: "pages", // Object Type slug
  slug: "home", // Object slug
  locale: "en", // optional, if localization set on Objects
})
.props("title,slug,metadata") // response properties

More examples

For more in-depth guides on getting Cosmic data into your app, you can view these basic query examples. When you are ready to level up, check out advanced query examples.

Add content

The Cosmic API is fully CRUD (create, read, update, delete) capable, enabling user-generated content and file uploads. Check out the add Object and add media examples in the documentation.

Further documentation

See the full documentation for more requests and capabilities.

Community support

For general help, please refer to the official Cosmic documentation. For additional help, you can use one of these channels to ask a question:

  • Slack (For live discussions with the Cosmic community and team)
  • GitHub (Bug reports, contributions)
  • Twitter (Get the latest news about Cosmic features and notifications)
  • YouTube (Learn from video tutorials)

License

This project is published under the MIT license.