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

@binary-brawlers/filebase-client

v0.1.1

Published

Framework-agnostic browser SDK for uploading files to a [FileBase](https://github.com/binary-brawlers/filebase) self-hosted upload gateway.

Readme

@binary-brawlers/filebase-client

Framework-agnostic browser SDK for uploading files to a FileBase self-hosted upload gateway.

Use this package directly in any browser app (vanilla JS, Svelte, Solid, Angular, etc.). If you're using React, React Native, Next.js, or Node.js, prefer the dedicated package — they all use this client under the hood.

Install

npm install @binary-brawlers/filebase-client

How it works

The browser never sees your FileBase API key. Instead:

  1. Your own backend exposes a sign endpoint that uses @binary-brawlers/filebase-node (or @binary-brawlers/filebase-next) to exchange the secret API key for a short-lived signed upload session.
  2. The browser calls FileBaseClient.upload(file), which:
    • POSTs to your sign endpoint to get a session,
    • then POSTs the file directly to the FileBase gateway with that session token.

Quick start

import { FileBaseClient, FileBaseError } from "@binary-brawlers/filebase-client";

const client = new FileBaseClient({
  signEndpoint: "/api/upload/sign",   // your own backend route
});

async function handleFile(file: File) {
  try {
    const result = await client.upload(file, {
      preset: "profile_images",       // matches a preset in your FileBase dashboard
      onProgress: ({ loaded, total, fraction }) => {
        console.log(`uploading ${loaded}/${total}`, fraction);
      },
    });
    console.log("uploaded:", result.url);
  } catch (err) {
    if (err instanceof FileBaseError) console.error(err.code, err.details);
  }
}

API

new FileBaseClient(options)

type FileBaseClientOptions = {
  signEndpoint: string;                // required
  fetch?: typeof fetch;                // optional override
  signHeaders?: Record<string, string>;
  signCredentials?: RequestCredentials; // default "same-origin"
};

client.upload(file, options?)

One-shot upload. Returns Promise<FileBaseUploadResult>.

type UploadOptions = {
  preset?: string;            // preset name
  presetId?: string;          // or preset id
  projectId?: string;
  expiresInSeconds?: number;  // override session TTL
  filename?: string;          // override file name in multipart
  contentType?: string;       // override mime
  fields?: Record<string, string>; // extra multipart fields
  onProgress?: (p: UploadProgress) => void;
  signal?: AbortSignal;
};

client.createSession(request?)

Just gets a session without uploading. Returns Promise<FileBaseUploadSession>.

client.uploadToSession(session, file, options?)

Upload to a pre-fetched session (useful if your backend hands the session to the browser as part of another response).

Cancellation

const controller = new AbortController();
client.upload(file, { signal: controller.signal });
controller.abort();

Sign endpoint contract

Your backend route must accept a POST with an optional JSON body of shape { preset?, presetId?, projectId?, expiresInSeconds? } and respond with:

{ "data": { "id": "…", "uploadUrl": "…", "token": "…", "expiresAt": "…" } }

The easiest way to implement this is with @binary-brawlers/filebase-next (App Router) or @binary-brawlers/filebase-node (Express, Fastify, etc.).

Errors

Throws FileBaseError (re-exported from @binary-brawlers/filebase-shared). See its code field for branching.

License

MIT