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

@spacefast/sdk

v0.8.0

Published

Typed TypeScript client for the Spacefast API, generated from the public OpenAPI spec.

Readme

@spacefast/sdk

The typed TypeScript client for the Spacefast API. Every path, parameter and response body is generated from the published OpenAPI spec, so the compiler knows which routes exist, which arguments they take, and what comes back — autocomplete a path string and the rest of the call types itself. No runtime dependencies, works anywhere fetch does.

Install

npm install @spacefast/sdk

Quickstart

import { createSpacefastClient, SpacefastApiError } from "@spacefast/sdk";

const client = createSpacefastClient({
  baseUrl: "https://api.spacefast.com",
  apiKey: process.env.SPACEFAST_API_KEY,
});

try {
  // Typed all the way through: the path picks the operation, `path` and `query`
  // are checked against it, and `space` is the space resource.
  const space = await client.get("/v1/spaces/{spaceId}", { path: { spaceId: "spc_..." } });
  console.log(space.slug, space.liveUrl);
} catch (error) {
  if (!(error instanceof SpacefastApiError)) throw error;
  // Failures are RFC 9457 problem documents, kept whole.
  console.error(error.status, error.code, error.message);
  console.error(error.pointer); // JSON Pointer into your body, on validation errors
  console.error(error.next); // copy-pasteable commands that fix it
  console.error(error.requestId); // quote this in a support request
}

Plain { data } responses unwrap to the resource. Paginated lists come back whole, so pagination is still there:

const { data: spaces, pagination } = await client.get("/v1/spaces", { query: { limit: 20 } });

Mutations take body, and any of them can carry an idempotencyKey that makes a retry safe.

Getting a credential

npm install -g spacefast
sf login
sf api-keys create --name "my-integration"

The key is shown once. Full auth docs: https://spacefast.com/docs/api.

What's in the box

| Import | What it gives you | | ----------------------------- | ---------------------------------------------------------------------- | | @spacefast/sdk | createSpacefastClient, SpacefastApiError, the operation index | | @spacefast/sdk/schema | The raw generated paths and components types | | @spacefast/sdk/query | TanStack Query factories for every operation | | @spacefast/sdk/transport | The HTTP core — retries, problem-document parsing — for custom clients | | @spacefast/sdk/publish | The publish pipeline: manifest, upload, finalize, wait | | @spacefast/sdk/openapi.json | The spec itself, for your own codegen |

@spacefast/sdk/query

Every operation also ships as TanStack Query option factories — <operationId>Options(), QueryKey(), InfiniteOptions(), Mutation() — plus a small invalidation vocabulary (bySpace, byTeam, STALE_TIME_MS). Spread one into any TanStack Query call:

import { getSpaceOptions, bySpace, STALE_TIME_MS } from "@spacefast/sdk/query";

const space = useQuery({
  ...getSpaceOptions({ path: { spaceId } }),
  staleTime: STALE_TIME_MS.normal,
});
queryClient.invalidateQueries({ queryKey: bySpace(spaceId) });

This layer authenticates with browser session cookies by default. Use configureSpacefastQuery({ apiKey, credentials: "omit" }) for one API key or partner token per process and cache. Point it at another API origin with the same call. Do not switch credentials without also replacing or clearing the QueryClient; credentials intentionally stay out of query keys.

@tanstack/react-query is an optional peer dependency, and only this subpath imports it.

@spacefast/sdk/publish

The four steps of a publish, importable as one barrel: build a manifest (manifestFileEntry), open a version (createVersionIntent), push the bytes (uploadSessionFiles), finalize and wait (finalizeVersion, waitUntil). publishDirect is the one-request shortcut for small payloads.

uploadSessionFiles requires the apiUrl you configured for the transport. That origin is what a relative upload target resolves against, and the only non-runtime origin an upload may reach. Pass your own configured value — never one read back out of the upload session.

Every request is then bound to the session response that origin returned: bytes go only to a host that response named, and only to a runtime upload endpoint naming your own Space or upload session. A route that merely looks like yours does not admit a host — the Space id in /spaces/<id>/blobs/<sha> is already in every legitimate target, so anyone could copy it.

Filesystem walking lives one level down in @spacefast/sdk/publish/node (collectManifest), which is Node-only and stays out of the barrel so browser bundles don't pull in node:fs.

The partner tier

Partner applications get the complete partner contract without local codegen:

import { createSpacefastPartnerClient } from "@spacefast/sdk/partner";

const partner = createSpacefastPartnerClient({
  baseUrl: "https://api.spacefast.com",
  apiKey: process.env.SPACEFAST_PARTNER_API_KEY,
});

const principals = await partner.get("/v1/principals", {
  query: { limit: 100 },
});

The partner family includes all consumer operations plus tenant, principal, usage, and other partner-only operations. It uses the same transport, SpacefastApiError, envelopes, retries, and idempotency behavior as the consumer client.

Use @spacefast/sdk/partner/query for TanStack Query and React Query:

import { QueryClientProvider, useQuery } from "@tanstack/react-query";
import { createSpacefastPartnerQueryScope } from "@spacefast/sdk/partner/query";

const scope = createSpacefastPartnerQueryScope({
  requestOrigin: "https://api.spacefast.com",
  identity: {
    type: "customer",
    teamId: partnerTeam.id,
    issuer: "https://partner.example",
    principalId: customer.id,
  },
  credential: {
    kind: "bearer-provider",
    getAccessToken: () => currentCustomerToken(),
  },
});

function Sites() {
  const sites = useQuery(scope.query.listSpacesOptions({ query: { limit: 50 } }));
  return <SiteList sites={sites.data?.data ?? []} />;
}

<QueryClientProvider client={scope.queryClient}>
  <Sites />
</QueryClientProvider>;

One scope owns one generated HTTP client and one QueryClient. Refreshing the token inside the same principal is safe. Create and dispose a scope when the principal changes, so cached customer data cannot cross identities.

Lower-level types and the exact generation input are available from @spacefast/sdk/partner/schema and @spacefast/sdk/openapi.partner.json.

Start at https://spacefast.com/docs/platforms/api/reference.

Also