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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@compasscms/sdk

v0.2.1

Published

Framework-neutral TypeScript SDK for the Compass CMS API.

Readme

@compasscms/sdk

npm version npm license

Framework-agnostic TypeScript client for the versioned Compass CMS HTTP API. Use it from Astro, Next.js, Vue, Svelte, Node.js, or any JavaScript runtime with fetch. It talks to the public API; it does not bundle the CMS dashboard or backend. A different CMS can use the client if it implements the Compass API contract.

Install

Install the SDK and its contracts peer package:

pnpm add @compasscms/sdk @compasscms/contracts
npm install @compasscms/sdk @compasscms/contracts

The contracts package supplies the types re-exported by the SDK and publishes the OpenAPI document.

Quick start

import { Compass } from "@compasscms/sdk";

const compass = new Compass({
	baseUrl: process.env.CMS_API_URL ?? "https://cms.example.com/api",
	apiKey: process.env.CMS_API_KEY,
});

const { items: posts } = await compass.posts.list({
	status: "published",
	pageSize: 10,
	tags: ["engineering"],
});

const post = await compass.posts.get("getting-started", { format: "markdown" });
console.log(post.title);

baseUrl is the API root. The SDK appends /v1/... paths, so use https://cms.example.com/api when the API is mounted under /api; do not add /v1 yourself. If your backend serves /v1 at the host root, use the host root as baseUrl.

Frameworks and runtimes

The client is framework-agnostic: it has no React, Vue, Svelte, or Astro runtime dependency. Use the same Compass instance in server load functions, route handlers, server-rendered pages, or browser code calling public read endpoints. Framework-specific hooks and reactive stores are not included.

For example, an Astro server-rendered page can use the client directly:

---
import { Compass } from "@compasscms/sdk";

const compass = new Compass({
	baseUrl: import.meta.env.CMS_API_URL,
	apiKey: import.meta.env.CMS_API_KEY,
});
const { items: posts } = await compass.posts.list({ status: "published" });
---

<main>
	{posts.map((post) => <h2><a href={`/blog/${post.slug}`}>{post.title}</a></h2>)}
</main>

Authentication and keys

Published content can be read without a key when the CMS deployment allows public reads. Otherwise, provide apiKey; requests send it as Authorization: Bearer <key>. Create API keys in the CMS dashboard. Keys are scoped to a project and can have content:read, content:read:drafts, content:write, or collections:read permissions.

Keep write-capable keys in server-side environment variables—never bundle them into a browser application. A read-only public key may be used client-side if that exposure is acceptable. Browser requests also require the API deployment to allow your site’s CORS origin.

Client options

| Option | Default | Description | | --- | --- | --- | | baseUrl | Required | API root; the SDK appends /v1/.... | | apiKey | None | Optional bearer token. | | org | None | Organization slug; set with project for project-scoped requests. | | project | None | Project slug; set with org for project-scoped requests. | | timeoutMs | 15000 | Timeout per request attempt. | | retries | 2 | Retries for transient read failures. | | retryDelayMs | 250 | Base delay in milliseconds; grows exponentially. | | fetch | globalThis.fetch | Optional compatible fetch implementation. |

Read requests retry network failures, HTTP 429, and HTTP 5xx responses. Mutating requests are never retried automatically.

Resources

| Resource | Methods | | --- | --- | | compass.posts | list, all, get, create, update, delete, publish, unpublish | | compass.collections | list, all, get | | compass.collection(id) | get, list, all, getEntry, create, update, delete | | compass.authors, compass.categories, compass.tags | list, all, get (read-only) | | compass.media | list, all, get, delete |

List methods return a page containing items, total, page, pageSize, and pageCount. The all methods return async iterators for consuming all pages:

for await (const entry of compass.collection("docs").all()) {
	console.log(entry.title);
}

Media uploads use the CMS dashboard’s authenticated storage flow and are not handled by the public media catalog resource.

Types and errors

The SDK re-exports types from @compasscms/contracts:

import type { Collection, Page, Post } from "@compasscms/sdk";
import { CompassError, isCompassError } from "@compasscms/sdk";

Failed HTTP responses throw CompassError, with status, code, and details when provided by the API. Network failures use status 0.

try {
	const post = await compass.posts.get("missing-post");
	console.log(post.title);
} catch (error) {
	if (isCompassError(error)) {
		console.error(error.status, error.code, error.message, error.details);
	}
}

Package size

Version 0.2.0 has no runtime dependencies and ships as a 21.1 kB packed npm tarball (69.9 kB unpacked). The required @compasscms/[email protected] package adds 17.6 kB packed (60.0 kB unpacked). These sizes include documentation and license files and may change between releases.

License

Licensed under the GNU Affero General Public License v3.0 only. See LICENSE.