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

@saplings/client

v0.3.1

Published

Reusable Saplings client toolkit

Readme

@saplings/client

Typed, application-defined JSON endpoints for browser and Node fetch clients.

Install

npm install @saplings/client

Quick start

import { createClient, type Endpoint } from '@saplings/client';

type Project = { id: string };
const getProject: Endpoint<string, Project> = {
  method: 'GET',
  path: (id) => `/api/projects/${encodeURIComponent(id)}`,
  parse(value) {
    if (!value || typeof value !== 'object' || !('id' in value) || typeof value.id !== 'string')
      throw new Error('Invalid project response');
    return { id: value.id };
  },
};
const client = createClient({ baseUrl: 'https://api.example.com' });
const project = await client.request(getProject, 'project-1');

API and operational notes

Request paths must remain on the configured origin and redirects are rejected. The supplied parser must validate response data. Configure authentication, CSRF protection, cross-origin credentials, retries and API policy in the consuming application. Requests time out after 12 seconds by default and support AbortSignal. Errors expose the HTTP status, not response bodies.

Validation

Run the workspace build and pnpm test after making changes. Confirm application-specific behavior and accessibility in the consuming environment.

Query parameters

import { withQuery } from '@saplings/client';
const path = withQuery('/api/projects', { query: 'design & research', page: 0 });

Query values are URL-encoded; null and undefined values are omitted. Choose retry, caching, CSRF and authentication behavior explicitly for your API.

Use getHeaders(signal) to resolve short-lived authorization or CSRF headers for each request. Dynamic headers override static headers. The callback receives the request cancellation signal; it must avoid logging credentials. The client does not automatically retry unsafe operations.

Typed starter session

import { createStarterSessionClient } from '@saplings/client';

const session = createStarterSessionClient({ baseUrl: location.origin, readRetries: 1 });
await session.change({ login, password });
const { signedIn, canOperate } = await session.read();
await session.change({ logout: true });

The client validates the response from the starter’s cookie-backed session endpoint. GET requests can retry HTTP 429, 502, 503 and 504 within the original deadline. Set readRetries between 0 (default) and 4. Writes execute once; callers can reconcile an uncertain outcome by reading the session again.

The typed starterCatalogPage endpoint accepts text, page, pageSize and optional sorting. Use client.request(starterCatalogPage, { text: 'billing', page: 0, pageSize: 20 }) to get validated SDK feature rows and counts.

A request aborted before it begins does not call the dynamic header provider or send a network request. HTTP error response bodies are discarded on a best-effort basis before returning the typed error.