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

@mortar-ai/client

v0.3.0

Published

TypeScript client for Mortar — Backend-as-a-Service for mainland-China-friendly mobile + web apps

Readme

@mortar-ai/client

TypeScript / JavaScript client for Mortar — a mainland-China-friendly Backend-as-a-Service.

Works in Node 20+, modern browsers, Cloudflare Workers, Deno, Bun, React Native — anywhere fetch exists.

Install

npm install @mortar-ai/client
# or pnpm / yarn / bun add

Project-scope client

Use this from your app code (mobile / web / server) to call Mortar's data APIs. Authenticated by your project's API key (created via the Mortar dashboard or POST /v1/{tenant}/_admin/keys).

import { createClient } from '@mortar-ai/client';

const mortar = createClient({
  // The tenant lives in the host subdomain (Supabase's `<ref>.supabase.co`
  // shape) — there is no separate `tenant` option.
  url: 'https://project-uuid.api.mortar.appunvs.com',
  apiKey: process.env.MORTAR_API_KEY!,
});

// Database
const todos = await mortar.from('todos').select({ limit: 50 });
const row = await mortar.from('todos').insert({ title: 'buy milk' });
await mortar.from('todos').update(row.id, { title: 'buy milk + eggs' });
await mortar.from('todos').delete(row.id);

// End-user auth
const { token, user } = await mortar.auth.signIn({
  email: '[email protected]',
  password: '...',
});
// Re-create the client with the user's token attached so RLS
// can key off them:
const userScoped = mortar.withUserToken(token);

// Storage
await userScoped.storage.upload({
  bucket: 'avatars',
  key: 'alice.jpg',
  body: file,            // Blob, ArrayBuffer, Uint8Array, Node stream
  contentType: 'image/jpeg',
});
const bytes = await userScoped.storage.downloadAsBytes({ bucket: 'avatars', key: 'alice.jpg' });

// Realtime — SSE subscription to row changes
const sub = mortar.realtime.subscribe(
  { table: 'todos' },
  (ev) => console.log(ev.op, ev.id, ev.data),
  (err) => console.error('realtime error:', err),
);
// later: sub.unsubscribe();

// Usage / credit dashboard
const usage = await mortar.usage.me();
console.log(`balance: ¥${usage.credit.balance_yuan}`);

Account-scope client

Use this from your control-plane code (CI scripts, admin tools, the mortar CLI itself) to manage your own Mortar account + projects.

import { createAccountClient } from '@mortar-ai/client/account';

const account = createAccountClient({ url: 'https://api.mortar.appunvs.com' });

// First-time
await account.signUp({ email: '[email protected]', password: 'hunter2' });
// or returning user
const { token } = await account.signIn({ email: '[email protected]', password: '...' });

// Projects
const projects = await account.projects.list();
const created = await account.projects.create({
  name: 'my-app-prod',
  tier: 'small',
  credit_mode: 'hard_budget',
});
await account.projects.update(created.id, { tier: 'medium' });
await account.projects.delete(created.id);

Errors

Every method throws MortarApiError on non-2xx responses. The error carries the HTTP status + the parsed JSON body.

import { MortarApiError } from '@mortar-ai/client';

try {
  await mortar.from('todos').insert({ title: 'x' });
} catch (e) {
  if (e instanceof MortarApiError && e.status === 402 && (e.body as any).error === 'credit_exhausted') {
    // Time to top up or wait for next billing period
  }
}

License

Apache-2.0 — see Mortar's main LICENSE.