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

@bytecask/react

v2026.7.5

Published

React bindings for bytecask — BytecaskProvider plus usePutBlob/useBlob/useStorageEstimate hooks over the content-addressed blob store.

Readme

@bytecask/react

React bindings for browser-native blob storage.

Connect React applications to Bytecask with an ownership-aware provider and typed hooks for uploads, reads, and browser storage estimates.

pnpm add @bytecask/core @bytecask/react react

npm downloads license React

Quick Start · Provider · Hooks · Browser Support · Documentation


What It Is

@bytecask/react is the optional React layer over @bytecask/core. It keeps storage policy in the core package and gives components predictable loading, missing, and error states without introducing a second storage abstraction.

Highlights

  • Small React surface: one provider and focused hooks over the core API.
  • Explicit ownership: providers close stores they create and preserve stores supplied by the host.
  • Typed async state: upload, lookup, estimate, and failure state are exposed without hiding the underlying BlobStore.
  • SSR-safe imports: importing the module does not construct browser storage; create providers and stores in a browser context.
  • React 18 and 19: both current application generations are supported.

Installation

pnpm add @bytecask/core @bytecask/react react

Add @bytecask/worker when the provider selects OPFS:

pnpm add @bytecask/core @bytecask/react @bytecask/worker react

Quick Start

import { BytecaskProvider, usePutBlob } from '@bytecask/react'

function UploadButton() {
  const { put, putting, error } = usePutBlob()

  return (
    <input
      type="file"
      disabled={putting}
      aria-invalid={error ? true : undefined}
      onChange={async (event) => {
        const file = event.currentTarget.files?.[0]
        if (file) console.log(await put(file))
      }}
    />
  )
}

export function App() {
  return (
    <BytecaskProvider options={{ backend: 'idb' }}>
      <UploadButton />
    </BytecaskProvider>
  )
}

The upload result is the lowercase BLAKE3 content hash. Keep that hash in the host's attachment record and let Bytecask own the corresponding bytes.

Provider Ownership

Let the provider construct and close its store:

<BytecaskProvider
  options={{
    backend: 'idb',
    idb: { databaseName: 'archive-blobs' },
    metadata: { databaseName: 'archive-metadata' },
  }}
>
  <AppRoutes />
</BytecaskProvider>

Or supply a store owned by the host:

<BytecaskProvider store={store}>
  <AppRoutes />
</BytecaskProvider>

The provider closes stores created from options when it unmounts. It does not close an explicitly supplied store.

Hooks

| Hook | Purpose | |---|---| | useBytecaskStore() | Access the current BlobStore | | usePutBlob() | Store a Blob and expose upload/error state | | useBlob(hash) | Resolve a hash to bytes with explicit status and error state | | useStorageEstimate() | Read usage, quota, and persistence information |

import { useBlob } from '@bytecask/react'

function Attachment({ hash }: { hash: string }) {
  const { status, bytes, error } = useBlob(hash)

  if (status === 'loading') return <span>Loading</span>
  if (error) return <span>Unavailable</span>
  if (status === 'missing') return <span>Restore required</span>
  if (status !== 'ready') return null
  return <span>{bytes?.byteLength ?? 0} bytes</span>
}

Missing bytes are a normal recoverable state: the host retains its attachment record and restores content from a trusted source when available.

Browser Support

  • React 18 and React 19 are accepted peer versions.
  • IndexedDB storage is tested in Chromium, Firefox, and Playwright WebKit.
  • OPFS storage is tested in Chromium and Firefox and requires @bytecask/worker.
  • The package is ESM-only and intended for modern browser applications.

Related Packages

| Package | Purpose | |---|---| | @bytecask/core | Required framework-neutral storage engine | | @bytecask/worker | Optional OPFS worker and streaming I/O |

Documentation

Security

Storage identity is not publisher identity. Verify signed containers or shards before loading untrusted bytes. Report vulnerabilities through the project's security policy.

License

AGPL-3.0-only. See LICENSE.