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

@bantis/storage-manager

v1.0.0

Published

A comprehensive storage and cookies manager library with cross-subdomain and encryption support.

Readme

@bantis/storage-manager

A comprehensive, secure, and easy-to-use library for managing browser storage (localStorage, sessionStorage) and cookies. Built with TypeScript, it seamlessly integrates with frontend frameworks like React and Angular, and offers native support for client-side encryption and cross-subdomain cookie sharing.

Features

  • 🔐 Built-in Encryption: Powered by @bantis/local-cipher v2 to automatically encrypt sensitive data stored in local/session storage or cookies.
  • 🍪 Advanced Cookie Management: Easily set, get, and remove cookies across all paths and share them across subdomains seamlessly.
  • 📦 Framework Agnostic: Works perfectly in Vanilla JS, React, Angular, Vue, etc.
  • 🛡️ Type Safety: Written in TypeScript with full type definitions included.
  • 🚀 Dual Exports (CJS & ESM): Bundled using tsup to ensure compatibility with modern bundlers.

Installation

npm install @bantis/storage-manager @bantis/local-cipher

Setup & Basic Usage

Unencrypted Usage

You can use the pre-instantiated exports directly out of the box if you don't need encryption:

import { localStore, sessionStore, cookies } from '@bantis/storage-manager';

// Local Storage
await localStore.set('myKey', { user: 'admin' });
const user = await localStore.get('myKey');
localStore.remove('myKey');

// Session Storage
await sessionStore.set('tempData', [1, 2, 3]);

// Cookies
await cookies.set('myTracker', 'tracker123', { expires: 7 }); // expires in 7 days
const myTracker = await cookies.get('myTracker');

Encrypted Usage (Recommended for Sensitive Data)

To enable encryption, instantiate the managers with a generic secret key. @bantis/local-cipher will handle everything securely under the hood using an asynchronous API.

import { createEncryptedStorage, createEncryptedCookieManager } from '@bantis/storage-manager';

const SECRET_KEY = 'your_super_secret_key_123';

// Setup encrypted storages
const secureStore = createEncryptedStorage('localStorage', SECRET_KEY);

await secureStore.set('authToken', 'ey...');
// Value in localStorage will be securely encrypted: "sm_enc_authToken": "U2FsdGVkX1..."

const token = await secureStore.get('authToken');
// returns 'ey...'
console.log(token);


// Setup encrypted cookies with cross-subdomain support
const secureCookies = createEncryptedCookieManager(SECRET_KEY, '.yourdomain.com');

// Sets an encrypted cookie accessible across site.com, api.site.com, app.site.com
await secureCookies.set('session_id', 'unique-hash-value', {
    domain: '.yourdomain.com', // ⚠️ Leading dot is important to share between subdomains
    expires: 30, // valid for 30 days
});

Framework Integration Examples

React Hook Example

You can easily wrap this manager in a custom React hook:

import { useState, useEffect } from 'react';
import { localStore } from '@bantis/storage-manager';

export function useLocalStore(key, initialValue) {
  const [value, setValue] = useState(initialValue);

  useEffect(() => {
    localStore.get(key).then((saved) => {
       if (saved !== null) {
          setValue(saved);
       } else {
          localStore.set(key, initialValue);
       }
    });
  }, [key]);

  const setNewValue = async (newValue) => {
    setValue(newValue);
    await localStore.set(key, newValue);
  };

  return [value, setNewValue];
}

Angular Service Example

You can wrap the encrypted manager in an injectable Angular Service:

import { Injectable } from '@angular/core';
import { createEncryptedCookieManager } from '@bantis/storage-manager';

@Injectable({
  providedIn: 'root'
})
export class AuthService {
  private secureCookies = createEncryptedCookieManager('my-super-secret', '.mycompany.com');

  async setToken(token: string): Promise<void> {
    await this.secureCookies.set('auth_token', token, { expires: 7 });
  }

  async getToken(): Promise<string | null> {
    return await this.secureCookies.get('auth_token');
  }

  logout(): void {
    this.secureCookies.remove('auth_token');
  }
}

API Reference

StorageManager

  • set<T>(key: string, value: T): Promise<void>
  • get<T>(key: string): Promise<T | null>
  • remove(key: string): Promise<void>
  • clear(): void

CookieManager

  • set<T>(key: string, value: T, options?: CookieOptions): Promise<void>
  • get<T>(key: string): Promise<T | string | null>
  • remove(key: string, options?: Pick<CookieOptions, 'path' | 'domain'>): void
  • clearAll(): void

Cookie Options:

  • expires?: number | Date: Number of days or a specific Date object.
  • path?: string: Cookie path, defaults to /.
  • domain?: string: Enable cross-subdomain sharing (e.g., .example.com).
  • secure?: boolean: Defaults to true on HTTPS.
  • sameSite?: 'Strict' | 'Lax' | 'None': Defaults to Lax.
  • secretKey?: string: Required if used directly to enable encryption.

License

MIT