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

@secure-storage/common

v1.0.8

Published

NPM package for storing and managing data across window local-storage and session-storage securely

Readme

Secure-Storage

npm

JavaScript TypeScript

Browser Only

Secure, type-safe, and effortless encrypted access to localStorage and sessionStorage in your web applications.


🔐 Why secure-storage?

Storing sensitive data in localStorage or sessionStorage without encryption is risky. secure-storage ensures your data is:

  • Encrypted before storage
  • Decrypted automatically on retrieval
  • Type-safe – no need to manually JSON.stringify or JSON.parse
  • Easy to use with both localStorage and sessionStorage

✨ Features

  • AES-based encryption under the hood
  • Automatically serializes and deserializes data
  • Works seamlessly with complex types (objects, arrays, etc.) and also custom user types.
  • Supports both localStorage and sessionStorage
  • Lightweight and dependency-free (or minimal deps)

⚠️ Important: Environment Requirement

This package is browser-only. It requires access to the window object and will not work in server-side environments like Node.js, Next.js SSR, or during static site generation (SSG).

🧠 Use this only in the browser – such as React, Next.js (client components only), Vue, or any SPA framework with client-side rendering.


📦 Installation

npm install @secure-storage/common

or

yarn add @secure-storage/common

🚀 Quick Start

You can configure you own hash and prefix using env with these variables

SECURE_STORAGE_SECRET="<your-hash-secret>"
SECURE_STORAGE_PREFIX="<your-prefix>"

For example in VITE vite.config.js

import { defineConfig } from "vite";
// ...
export default defineConfig({
  // ...
  define: {
    "process.env": {
        SECURE_STORAGE_SECRET="ze329jdfjhf348ad"
        SECURE_STORAGE_PREFIX="my-secure-storage"
    },
  },
});

Also you can configure via the configure function

import { configure } from "@secure-storage/common";

configure({
  secret: "ze329jdfjhf348ad",
  prefix: "my-secure-storage",
});

Here is an example usage

import { localStorage, sessionStorage } from "@secure-storage/common";

// Save data
localStorage.setItem("user", { name: "Alice", age: 30 });
sessionStorage.setItem("loggedData", { session: "sdh34as9uiw" });

// Retrieve data - defaults type to "string|number|object|boolean|undefined|null"
const user = localStorage.getItem("user");
const loggedData = sessionStorage.getItem("loggedData");

// Retrieve data (typed) - inherits the user passed type to variable
const userTyped = localStorage.getItem<{ name: string; age: number }>("user");
const loggedDataTyped = sessionStorage.getItem<{ session: string }>(
  "loggedData"
);

// Remove data
localStorage.removeItem("user");
sessionStorage.removeItem("loggedData");

// Clear - checks prefix match then removes sequentially
localStorage.clear();
sessionStorage.clear();

// Force clear - works similar to storage.clear()
localStorage.forceClear();
sessionStorage.forceClear();

How can I contribute ?

To contribute on the library, make sure you are creating a development branch for your fix as dev-{feature/fix name} and create a PR to main branch.

You can test your changes using npm run test or npm run dev-test before pushing.