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

@enjoys/react-api

v0.0.8

Published

[![npm version](https://img.shields.io/npm/v/@enjoys/react-api)](https://www.npmjs.com/package/@enjoys/react-api) [![license](https://img.shields.io/npm/l/@enjoys/react-api)](./LICENSE.md) [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue)

Downloads

49

Readme

@enjoys/react-api

npm version license TypeScript

A collection of type-safe React hooks and utilities for browser-native APIs — IndexedDB, Cache Storage, File System Access, and Custom Events.


Features

| Module | Description | Import | |---|---|---| | IDB | IndexedDB via Dexie — typed CRUD, QueryBuilder, operators, nested objects, TTL pruning | @enjoys/react-api/idb | | Cache Storage | Browser Cache API — JSON, Blob, File, HTML, ArrayBuffer with TTL & metadata | @enjoys/react-api/cache-storage | | Events | Cross-component CustomEvent hook — emit, listen, debounce, fire-once | @enjoys/react-api/events | | OFS | File System Access API — read/write/delete files with nested directory support | @enjoys/react-api/ofs |


Installation

npm install @enjoys/react-api

Peer Dependencies

| Package | Required | Used by | |---|---|---| | react ^18 || ^19 | Yes | All modules | | react-dom ^18 || ^19 | Yes | All modules | | dexie ^4 | Optional | IDB module | | dot-object ^2 | Optional | IDB nested operations |

# Install peer deps for IDB module
npm install dexie dot-object

Quick Start

IndexedDB

import { IDB, type TableSchema, createQueryBuilder, equals, above } from '@enjoys/react-api/idb';
import { type EntityTable } from 'dexie';

// Step 1: Define your entity
interface User {
  id: string;
  name: string;
  age: number;
}

// Step 2: Define Tables — pick the primary key per table via EntityTable<Entity, PK>
//         PK must be a key of the entity ('id' | 'name' | 'age' here)
type Tables = {
  users: EntityTable<User, 'id'>; // ← 'id' is the chosen primary key
};

// Step 3: Define schema — TypeScript auto-enforces the PK from Step 2
//         '++' prefix = auto-increment; remaining fields = indexed columns
const schema = {
  users: '++id,name,age', // ← 'id' must appear first; 'name','age' are optional indexes
} satisfies TableSchema<Tables>;

const idb = new IDB<Tables>(schema, 'my-app', 1);

// CRUD
await idb.addItem('users', { id: '1', name: 'Alice', age: 30 });
const user = await idb.getItemByKey('users', '1');

// QueryBuilder
const qb = createQueryBuilder(idb.getRawDb());
const adults = await qb.query('users').where({ age: above(18) }).findMany();

Cache Storage

import { useCache } from '@enjoys/react-api/cache-storage';

function App() {
  const cache = useCache('my-app');

  const load = async () => {
    await cache.put('user', { name: 'Alice' }, 3600);
    const user = await cache.get('user');
    const fresh = await cache.getOrSet('profile', () => fetch('/api/me').then(r => r.json()), 600);
  };

  return <button onClick={load}>Load</button>;
}

Events

import { useReactEvent } from '@enjoys/react-api/events';

function Sender() {
  const { emit } = useReactEvent('notify');
  return <button onClick={() => emit({ msg: 'hello' })}>Send</button>;
}

function Receiver() {
  const { listen } = useReactEvent('notify');
  useEffect(() => listen((data) => console.log(data)), [listen]);
  return null;
}

Documentation

| Module | Guide | |---|---| | IndexedDB | IDB Documentation | | Cache Storage | Cache Storage Documentation | | Events | Events Documentation | | OFS (File System) | OFS Documentation |


Tree-Shakable Imports

Each module is a separate entry point — only the code you import gets bundled:

import { IDB } from '@enjoys/react-api/idb';           // Only IDB
import { useCache } from '@enjoys/react-api/cache-storage'; // Only Cache
import { useReactEvent } from '@enjoys/react-api/events';   // Only Events
import { useOFS } from '@enjoys/react-api/ofs';             // Only OFS

Supports both ESM (import) and CJS (require).


Contributing

Contributions are welcome! Please open an issue or submit a pull request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -m 'feat: add my feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Open a Pull Request

License

MIT — made with care by ENJOYS