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

safe-session-storage

v1.0.3

Published

A secure wrapper for localStorage and sessionStorage with automatic encryption.

Downloads

187

Readme

safe-session-storage

A secure, lightweight wrapper for localStorage, sessionStorage, and AsyncStorage (React Native) with automatic encryption. Prevent casual inspection of your application's stored data across all platforms.

safe-session-storage CLI Demo

Features

  • Automatic Encryption: Data is encrypted before being stored.
  • React & React Native Support: Hooks for both synchronous and asynchronous storage.
  • SSR Friendly: Works perfectly with Next.js and other SSR frameworks.
  • Zero External Dependencies: Lightweight and fast.
  • Type Safe: Full TypeScript support.

Installation

npm install safe-session-storage

Platform Support

1. Web (React, Vite, etc.)

Use useSafeStorage for synchronous localStorage or sessionStorage.

import { useSafeStorage } from 'safe-session-storage';

function App() {
  const [theme, setTheme] = useSafeStorage('theme', 'light');
  // ...
}

2. Next.js (SSR)

useSafeStorage is SSR-safe. It detects the environment and returns the initial value during server-side rendering, then hydrates correctly on the client.

3. React Native

Use useAsyncSafeStorage with @react-native-async-storage/async-storage.

import AsyncStorage from '@react-native-async-storage/async-storage';
import { useAsyncSafeStorage } from 'safe-session-storage';

function Profile() {
  const [user, setUser, loading] = useAsyncSafeStorage('user', null, {
    customStorage: AsyncStorage,
    secretKey: 'my-mobile-secret'
  });

  if (loading) return <Text>Loading...</Text>;
  // ...
}

Usage

Vanilla JavaScript / TypeScript

import { safeLocal, SafeStorage, AsyncSafeStorage } from 'safe-session-storage';

// Web (Sync)
safeLocal.setItem('key', 'value');

// React Native / Custom (Async)
const asyncStore = new AsyncSafeStorage({ 
  customStorage: AsyncStorage,
  secretKey: 'key' 
});
await asyncStore.setItem('key', 'value');

Why use this?

When you store data in storage engines, it is usually stored in plain text. Anyone with access to the device or a malicious script can easily read this data.

safe-session-storage obfuscates this data using XOR encryption and Base64 encoding. It works across:

  • Browsers: Chrome, Firefox, Safari, Edge.
  • Server: Node.js (SSR safe).
  • Mobile: React Native (iOS/Android).

API

Web (Sync)

  • useSafeStorage(key, initialValue, options)
  • safeLocal / safeSession instances.
  • SafeStorage class.

Mobile/Custom (Async)

  • useAsyncSafeStorage(key, initialValue, options)
  • AsyncSafeStorage class.

Contribution

Feel free to fork and improve this project! Pull requests are welcome.

License

This project is licensed under the Apache-2.0 License.