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

@lonewolfspace/storage-manager-ts

v1.0.0-beta

Published

A universal browser storage manager with optional AES encryption support for localStorage, sessionStorage, and cookies.

Downloads

33

Readme

Storage Manager for Browser-Based JavaScript Frameworks

A universal browser and server storage manager for Next.js projects with support for localStorage, sessionStorage, and cookies, with optional AES encryption.


📦 Installation

npm install @lonewolfspace/storage-manager-ts
# or
yarn add @lonewolfspace/storage-manager-ts

✨ Features

  • 🔐 Optional AES encryption support
  • 🧱 Unified API for localStorage, sessionStorage, and cookies
  • ✅ TypeScript support (Syntactic Sugar)
  • ✅ Safe for use in client components
  • 📦 Cookie operations based on js-cookie
  • 📄 Modular import and usage flexibility
  • 🌐 Support for server-side cookie storage in Next.js API routes and Server Actions

🔧 Configuration

Client-side Configuration

import { StorageManagerConfig } from "@lonewolfspace/storage-manager-ts";

StorageManagerConfig.configureClient({
  encryption: true,
  keyPrefix: "secure_", // This option is under development 🚧
  secretKey: "your-128bit-secret-key", // Load from .env 🔐 (for Nextjs make sure to use "NEXT_PUBLIC_" prefix)
});

Server-side Configuration

import { StorageManagerConfig } from "@lonewolfspace/storage-manager-ts";

StorageManagerConfig.configureServer({
  encryption: true,
  keyPrefix: "secure_", // This option is under development 🚧
  secretKey: "your-128bit-secret-key", // Load from .env 🔐 
});

🔐 Set Secret Key for Encryption (Optional)

StorageManager.local.setSecretKey("your-secret-key");
StorageManager.session.setSecretKey("your-secret-key");
StorageManager.cookie.setSecretKey("your-secret-key");

⚠️ If you skip setting a secret key, values will be stored in plain text.


💾 Usage Examples

📦 LocalStorage Example

StorageManager.local.setItem("key", "value");
const value = StorageManager.local.getItem("key");
StorageManager.local.removeItem("key");

🗂 SessionStorage Example

StorageManager.session.setItem("sessionKey", "sessionValue");
const value = StorageManager.session.getItem("sessionKey");
StorageManager.session.removeItem("sessionKey");

🍪 Cookie Example (Client-side Only)

StorageManager.cookie.setCookie("cookieKey", "cookieValue", {
  path: "/",
  maxAge: 60 * 60 * 24, // 1 day
});

const cookie = StorageManager.cookie.getCookie("cookieKey");
StorageManager.cookie.deleteCookie("cookieKey");

⚙️ Use in Next.js Client Components

"use client";

import { StorageManager } from "@lonewolfspace/storage-manager-ts";

StorageManager.local.setItem("theme", "dark");
const theme = StorageManager.local.getItem("theme");

🧩 Modular Import

import {
  StorageManagerConfig,
  ClientLocalStorageManager,
  ClientSessionStorageManager,
  ClientCookieManager,
} from "@lonewolfspace/storage-manager-ts";

ClientLocalStorageManager.setItem("foo", "bar");
ClientSessionStorageManager.setItem("foo", "bar");
ClientCookieManager.setCookie("foo", "bar");

🌐 Server-side Cookie Storage

✅ API Route Example

// app/api/cookie/route.ts

import { StorageManagerConfig } from "@lonewolfspace/storage-manager-ts";
import { ServerCookieManager } from "@lonewolfspace/storage-manager-ts/server";
import { redirect } from "next/navigation";

StorageManagerConfig.configureServer({
  encryption: true,
  keyPrefix: "secret_",
  secretKey: "0000000000000000",
});

export async function GET() {
  await ServerCookieManager.setCookie("server_cookie", "Hello World");
  redirect("/");
}

✅ Server Action Example

"use server";

import { ServerCookieManager } from "@lonewolfspace/storage-manager-ts/server";

export const store_cookie = async () => {
  await ServerCookieManager.setCookie("server_cookie", "Hello World", {
    maxAge: 10,
  });
};

Then use this with form actions

✅ Usage in layout.tsx

import { StorageManagerConfig } from "@lonewolfspace/storage-manager-ts";
import { ServerCookieManager } from "@lonewolfspace/storage-manager-ts/server";

export default async function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  StorageManagerConfig.configureServer({
    encryption: true,
    keyPrefix: "secret_",
    secretKey: "0000000000000000", 
  });

  return <>...</>;
}

🧪 Client Demo Page Example

"use client";
import React, { useEffect, useState } from "react";
import {
  StorageManagerConfig,
  ClientLocalStorageManager,
  ClientSessionStorageManager,
  ClientCookieManager,
} from "@lonewolfspace/storage-manager-ts";

const StoragePage = () => {
  StorageManagerConfig.configureClient({
    encryption: false,
    keyPrefix: "secret_",
    secretKey: "0000000000000000",
  });

  const [message, setMessage] = useState("");

  useEffect(() => {
    const local = ClientLocalStorageManager.getItem("greeting");
    const session = ClientSessionStorageManager.getItem("session");
    const cookie = ClientCookieManager.getCookie("client_cookie");

    console.log("LocalStorage:", local);
    console.log("SessionStorage:", session);
    console.log("Client Cookie:", cookie);
  }, []);

  return (
    <div className="p-4 space-y-4">
      <h1 className="text-xl font-bold">Storage Test (Client)</h1>

      <button
        onClick={() => {
          ClientLocalStorageManager.setItem("greeting", "Hello Local!");
          setMessage("Stored in localStorage");
        }}
        className="px-4 py-2 bg-blue-500 text-white rounded"
      >
        Set LocalStorage
      </button>

      <button
        onClick={() => {
          ClientSessionStorageManager.setItem("session", "Hello Session!");
          setMessage("Stored in sessionStorage");
        }}
        className="px-4 py-2 bg-green-500 text-white rounded"
      >
        Set SessionStorage
      </button>

      <button
        onClick={() => {
          ClientCookieManager.setCookie("client_cookie", "Hello Cookie!", {
            expires: 1,
          });
          setMessage("Stored in client cookies");
        }}
        className="px-4 py-2 bg-purple-500 text-white rounded"
      >
        Set Client Cookie
      </button>

      <div className="text-gray-700">{message}</div>
    </div>
  );
};

export default StoragePage;

🧾 API Reference

StorageManager.local / StorageManager.session

| Method | Description | | --------------------- | --------------------------- | | setSecretKey(key) | Sets the AES encryption key | | setItem(key, value) | Stores the value | | getItem(key) | Retrieves the value | | removeItem(key) | Deletes the key |

StorageManager.cookie

| Method | Description | | --------------------------------- | --------------------------- | | setSecretKey(key) | Sets the AES encryption key | | setCookie(key, value, options?) | Sets a cookie | | getCookie(key) | Gets a cookie value | | deleteCookie(key, options?) | Deletes the cookie |

ServerCookieManager

| Method | Description | | --------------------------------- | ----------------------------- | | setCookie(key, value, options?) | Sets a cookie on the server | | getCookie(key) | Gets a cookie from the server | | deleteCookie(key, options?) | Deletes a server cookie |


📄 License

MIT © Manas Saha Roy