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

@alsaifdev/localdb

v1.0.0

Published

A lightweight browser-based localStorage database with real-time multi-tab sync and a clean proxy-based API.

Downloads

61

Readme

localdb

A lightweight browser-based localStorage database with real-time multi-tab sync and a clean proxy-based API — inspired by Appwrite.

Features

  • 🗄️ localStorage — কোনো server ছাড়াই persistent storage
  • Real-time multi-tab sync — BroadcastChannel দিয়ে সব tab instantly update
  • 🎯 Proxy-based APIdb.users.create() এর মতো সহজ syntax
  • 🔷 Full TypeScript — type-safe generics সহ
  • 🪶 Zero dependencies — মাত্র ~2KB gzipped
  • 🔔 Event system.on() এবং .subscribe() দুটোই

Installation

# npm
npm install localdb

# bun
bun add localdb

# yarn
yarn add localdb

Quick Start

import Database from "localdb";

const db = new Database();

// Create
const user = await db.users.create({ name: "Abdullah", role: "admin" });

// List all
const users = await db.users.list();

// Filter
const admins = await db.users.list({ role: "admin" });

// Get one
const user = await db.users.get("some-id");

// Update
await db.users.update("some-id", { name: "Al Saif" });

// Delete
await db.users.delete("some-id");

TypeScript Generics

interface User {
  name: string;
  role: "admin" | "user";
  age: number;
}

// Type-safe collection
const user = await db.users.create<User>({ name: "Abdullah", role: "admin", age: 25 });
// user.$id, user.name, user.createdAt — সব typed

Real-time Events

.on() — নির্দিষ্ট event শোনো

// unsubscribe function return করে
const unsub = db.users.on("create", ({ event, payload }) => {
  console.log("নতুন user:", payload.name);
});

// cleanup
unsub();

.subscribe() — সব event (create, update, delete)

const unsub = db.users.subscribe(({ event, payload }) => {
  console.log(`[${event}]`, payload);
});

// cleanup
unsub();

Multi-tab Sync

Tab A-তে data পরিবর্তন করলে Tab B-তে subscriber instantly fire হবে:

// Tab A
await db.products.create({ title: "Keyboard", price: 1200 });

// Tab B — automatically triggered!
db.products.on("create", ({ payload }) => {
  console.log("নতুন product এলো:", payload.title);
});

API Reference

Collection Methods

| Method | Signature | Description | |--------|-----------|-------------| | list | (query?) => Promise<Doc[]> | সব document বা filtered list | | create | (data, id?) => Promise<Doc> | নতুন document তৈরি | | get | (id) => Promise<Doc> | একটি document | | update | (id, data) => Promise<Doc[]> | document update | | delete | (id) => Promise<Doc[]> | document delete | | on | (event, cb) => unsubFn | নির্দিষ্ট event শোনো | | subscribe | (cb) => unsubFn | সব event শোনো | | off | (event, cb) => void | listener সরাও | | unsubscribe | (cb) => void | সব listener সরাও |

Database Methods

db.clear("users");  // একটি collection মুছো
db.clear();         // সব collection মুছো
db.destroy();       // BroadcastChannel বন্ধ করো (cleanup)

Document Structure

প্রতিটি document-এ automatically যোগ হয়:

{
  $id: string;        // UUID (auto-generated বা custom)
  createdAt: string;  // UTC string
  updatedAt: string;  // UTC string
  ...yourData
}

React Example

import { useEffect, useState } from "react";
import Database, { Document } from "localdb";

const db = new Database();

interface Todo { text: string; done: boolean; }

function TodoApp() {
  const [todos, setTodos] = useState<Document<Todo>[]>([]);

  useEffect(() => {
    // initial load
    db.todos.list<Todo>().then(setTodos);

    // real-time sync (এই tab + অন্য সব tab)
    const unsub = db.todos.subscribe(() => {
      db.todos.list<Todo>().then(setTodos);
    });

    return unsub;
  }, []);

  const addTodo = async (text: string) => {
    await db.todos.create<Todo>({ text, done: false });
  };

  return (
    <div>
      {todos.map(todo => <div key={todo.$id}>{todo.text}</div>)}
      <button onClick={() => addTodo("নতুন কাজ")}>Add</button>
    </div>
  );
}

Browser Support

BroadcastChannel এবং localStorage সব modern browser সমর্থন করে।

| Chrome | Firefox | Safari | Edge | |--------|---------|--------|------| | ✅ 54+ | ✅ 38+ | ✅ 15.4+ | ✅ 79+ |

License

MIT © Abdullah Al Saif