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

unstorage-sync

v0.1.0

Published

Synchronous Universal Storage Layer

Downloads

1,776

Readme

unstorage-sync

npm version npm downloads License

A synchronous fork of unstorage — same multi-driver, mountable, key-value API, but every operation is sync. No promises, no await.

When to use

Use unstorage-sync when you need a small key-value abstraction over storage backends that are themselves synchronous: in-memory maps, LRU caches, localStorage / sessionStorage, or Node fs.*Sync. The original unstorage is the right choice if you need async backends like Redis, S3, Cloudflare KV, etc.

Features

  • Fully synchronous API — getItem/setItem/getKeys/... all return values directly
  • Unix-style driver mounting to combine multiple storages under one tree
  • Default in-memory storage
  • Auto JSON value serialization and deserialization
  • Binary and raw value support
  • Snapshots and hydration (snapshot / restoreSnapshot)
  • Storage watcher
  • Tree-shakable utils and tiny core

Install

npm install unstorage-sync
# or
pnpm add unstorage-sync
# or
yarn add unstorage-sync

Usage

import { createSyncStorage } from "unstorage-sync";
import memory from "unstorage-sync/drivers/memory";

const storage = createSyncStorage({ driver: memory() });

storage.setItem("foo:bar", { hello: "world" });

const value = storage.getItem("foo:bar");
// → { hello: "world" }

storage.hasItem("foo:bar"); // → true
storage.getKeys("foo");     // → ["foo:bar"]
storage.removeItem("foo:bar");

Mounting drivers

import { createSyncStorage } from "unstorage-sync";
import memory from "unstorage-sync/drivers/memory";
import fs from "unstorage-sync/drivers/fs";

const storage = createSyncStorage();
storage.mount("/cache", memory());
storage.mount("/data", fs({ base: "./data" }));

storage.setItem("/data/users.json", { name: "Ada" });
storage.setItem("/cache/sessions:abc", "token");

Prefixed storage

import { createSyncStorage, prefixStorage } from "unstorage-sync";

const storage = createSyncStorage();
const userStorage = prefixStorage(storage, "user");

userStorage.setItem("name", "Ada");
storage.getItem("user:name"); // → "Ada"

Snapshots

import { snapshot, restoreSnapshot } from "unstorage-sync";

const data = snapshot(storage, "/data");
restoreSnapshot(otherStorage, data, "/data");

Watching changes

const unwatch = storage.watch((event, key) => {
  console.log(event, key); // "update" | "remove", key
});

storage.setItem("foo", "bar"); // triggers watcher
unwatch();

Built-in drivers

| Driver | Import | Backend | |---|---|---| | memory | unstorage-sync/drivers/memory | In-memory Map (default) | | lru-cache | unstorage-sync/drivers/lru-cache | lru-cache | | localstorage | unstorage-sync/drivers/localstorage | window.localStorage | | session-storage | unstorage-sync/drivers/session-storage | window.sessionStorage | | fs | unstorage-sync/drivers/fs | Node fs (sync), with ignore patterns | | fs-lite | unstorage-sync/drivers/fs-lite | Node fs (sync), minimal | | null | unstorage-sync/drivers/null | No-op | | overlay | unstorage-sync/drivers/overlay | Layered driver over other sync drivers |

Note: unstorage-sync only ships drivers whose backing storage is natively synchronous. For async backends (HTTP, Redis, Cloudflare KV, S3, etc.), use unstorage.

Custom drivers

Any object matching the Driver interface from unstorage-sync can be passed via mount() or createSyncStorage({ driver }). All driver methods must be synchronous.

import type { Driver } from "unstorage-sync";

const myDriver: Driver = {
  name: "custom",
  hasItem(key) { /* ... */ return false; },
  getItem(key) { /* ... */ return null; },
  setItem(key, value) { /* ... */ },
  removeItem(key) { /* ... */ },
  getKeys() { return []; },
};

Differences from upstream unstorage

  • createStorage is renamed to createSyncStorage
  • Every method on Storage and Driver is synchronous — return types are no longer wrapped in Promise
  • Async-only drivers (HTTP, Redis, S3, Azure, Cloudflare, MongoDB, Vercel, Netlify, Deno KV, etc.) are removed
  • fs driver loses its chokidar-based watch() (no sync watcher equivalent); use fs.watch directly if needed
  • The HTTP server and tracing entrypoints are removed

Credits

This is a fork of unstorage by @pi0 and the unjs contributors, distributed under the same MIT license.

License

MIT