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

@mojimoto/client

v0.2.0

Published

Typed client for the Mojimoto content delivery API.

Downloads

45

Readme

@mojimoto/client

Typed, dependency-light client for the Mojimoto content delivery API. Works in any environment with fetch (Node 18+, browsers, edge runtimes, Deno, Bun).

npm i @mojimoto/client

Create a client

import { createClient } from '@mojimoto/client';

const cms = createClient({
  endpoint: 'https://cms.yourikigai.co.uk/api/v1', // your delivery endpoint
  project: 'decentenergy',                          // project slug
  token: process.env.MOJIMOTO_TOKEN!,               // read token
});

Options

| Option | Type | Description | | --- | --- | --- | | endpoint | string | Required. Base delivery endpoint (no trailing project slug). | | project | string | Required. Project slug. | | token | string | Required. Read token (preview ability for drafts). | | lang | string | Default locale applied when a call omits one. | | preview | boolean | Request drafts (?ref=preview) by default. | | fetch | typeof fetch | Custom fetch (e.g. for Node < 18 or instrumentation). | | headers | Record<string,string> | Extra headers merged into every request. |

Methods

// List a single page; returns the full paginated envelope.
const { results, total_pages } = await cms.query({ type: 'blog_post', page: 1, perPage: 20 });

// Fetch every page and flatten (uses per_page=100 internally).
const allPosts = await cms.all({ type: 'blog_post' });

// First match for a query, or null.
const latest = await cms.first({ type: 'blog_post' });

// First document of a type with a given uid, or null.
const home = await cms.byUid('marketing_page', 'home');

// A single document by numeric id (throws MojimotoError if missing).
const doc = await cms.byId(42);

Every method accepts per-call lang, preview, and an AbortSignal:

const controller = new AbortController();
const posts = await cms.query({ type: 'blog_post', lang: 'fr-fr', signal: controller.signal });

Typed documents

Pair with the per-project types from php artisan mojimoto:generate-types:

import type { MojimotoDocument } from '@mojimoto/client';
import type { BlogPostData } from './mojimoto.generated';

type BlogPost = MojimotoDocument<'blog_post', BlogPostData>;

const post = await cms.byUid<BlogPost>('blog_post', 'why-switch');
post?.data.title; // ✅ fully typed, including resolved references

Resolved references

reference / references fields arrive already resolved to the linked document's data (one level deep). Type them with MojiReference:

import type { MojiReference, MojimotoDocument } from '@mojimoto/client';

interface PageData {
  author: MojiReference<MojimotoDocument<'author', AuthorData>>;
  related: MojiReference<MojimotoDocument<'blog_post', BlogPostData>>[];
}

Error handling

Non-2xx responses throw a MojimotoError:

import { MojimotoError } from '@mojimoto/client';

try {
  await cms.byId(999999);
} catch (err) {
  if (err instanceof MojimotoError) {
    console.error(err.status, err.body); // e.g. 404, { message: '…' }
  }
}

The token is never included in err.url.

License

MIT © Your Ikigai Ltd