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

@deloc/client

v0.3.1

Published

Browser SDK for calling Deloc Actions from published apps

Readme

@deloc/client

Browser SDK for calling Deloc Actions from a published app.

Actions are server-side endpoints (HTTP, SQL, scheduled jobs) that the app owner configures on Deloc's dashboard. This package is what the browser-side code calls to invoke them and to read back the history of recent invocations.

Install

npm install @deloc/client

Requirements

This SDK is designed to run inside a Deloc-hosted app (a page served from *.deloc.dev or a custom domain pointed at Deloc). It talks to the Worker-hosted dispatch endpoints on the same origin and relies on the viewer's session cookie for authentication — there are no API keys to manage and no configuration to pass.

It will not work when loaded from a third-party origin.

Usage

Vanilla

import { action } from "@deloc/client";

const result = await action<{ ok: boolean }>("submit_form", {
  email: "[email protected]",
  message: "hello",
});

if (result.success) {
  console.log(result.data); // { ok: true }
} else {
  console.error(result.error, result.errorType);
}

action() never throws for well-formed failures — it returns a discriminated union ({ success: true, data } or { success: false, error, errorType }). It only throws on transport errors (offline, aborted fetch, malformed response).

React

import { useDelocAction } from "@deloc/client/react";

function SubmitButton() {
  const { invoke, loading, error, data } = useDelocAction("submit_form");

  return (
    <button
      onClick={() => invoke({ email: "[email protected]" })}
      disabled={loading}
    >
      {loading ? "Sending…" : "Submit"}
      {error && <span>{error.message}</span>}
      {data && <span>Sent!</span>}
    </button>
  );
}

Pending requests are aborted automatically on unmount or when invoke is called again before the previous one resolves.

Reading invocations

Actions write every invocation to an append-only log. This is useful for "show pending updates before the next data refresh" UIs — overlay recent writes on top of the bundled JSON your app ships with.

import { invocations } from "@deloc/client";

const { invocations: rows } = await invocations({
  action: "update_status",
  status: "success",
  limit: 50,
});

Or as a React hook with auto-pagination:

import { useDelocInvocations } from "@deloc/client/react";

const { invocations, loading } = useDelocInvocations({
  action: "update_status",
  autoPaginate: true,
  maxRows: 500,
});

For idempotency checks keyed on an external id:

import { useDelocInvocationsByExternalId } from "@deloc/client/react";

const { invocations } = useDelocInvocationsByExternalId(row.id);

The hook stays idle (no request) when the id is nullish.

API

| Export | What it does | | --- | --- | | action(name, body?, options?) | Invoke an action. Returns ActionResult<T>. | | invocations(filters?) | Fetch one page of the invocation log. | | fetchAllInvocations(options?) | Auto-paginate. Capped at maxRows (default 1000). | | useDelocAction(name) | React hook wrapping action(). | | useDelocInvocations(options) | React hook wrapping invocations(). Supports polling and auto-pagination. | | useDelocInvocationsByExternalId(id, options?) | Convenience wrapper for idempotency lookups. |

Filters on invocations() / useDelocInvocations:

  • action — machine name of a single action
  • externalId — the id recorded at invocation time
  • since, before — ISO-8601 datetime bounds
  • status"success" or "error"
  • limit — 1..200 (clamped silently)

Error types

Failures carry an errorType so you can branch on cause:

  • timeout — the upstream didn't respond in time
  • rate_limit — the viewer hit the per-session rate limit
  • ssrf_blocked, domain_not_allowed, content_type_blocked — the action's URL or response was blocked by policy
  • forbidden_role — the viewer's role isn't allowed to invoke this action
  • upstream_error — HTTP 5xx from the upstream, or malformed response
  • schema_invalid — the request body didn't match the action's input schema
  • response_too_large — the upstream response exceeded the size limit

License

MIT