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

@molecule/app-storage-async-storage

v1.0.1

Published

AsyncStorage provider for @molecule/app-storage (React Native)

Readme

@molecule/app-storage-async-storage

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

AsyncStorage provider for @molecule/app-storage.

This package provides a React Native AsyncStorage-based implementation of the molecule StorageProvider interface, with support for key prefixing and custom serialization.

Quick Start

import { createAsyncStorageProvider } from '@molecule/app-storage-async-storage'
import { setProvider } from '@molecule/app-storage'

const storage = createAsyncStorageProvider({
  prefix: 'myapp_',
})

setProvider(storage)

// Use via `@molecule/app-storage`
import { get, set, remove } from '@molecule/app-storage'

await set('user', { name: 'John' })
const user = await get<User>('user')
await remove('user')

Type

provider

Installation

npm install @molecule/app-storage-async-storage @molecule/app-i18n @molecule/app-logger @molecule/app-storage @react-native-async-storage/async-storage

API

Interfaces

AsyncStorageConfig

AsyncStorage-specific configuration.

interface AsyncStorageConfig {
  /**
   * Key prefix for all stored values.
   * Useful for namespacing storage in shared environments.
   */
  prefix?: string

  /**
   * Custom serializer function.
   * @default JSON.stringify
   */
  serialize?: <T>(value: T) => string

  /**
   * Custom deserializer function.
   * @default JSON.parse
   */
  deserialize?: <T>(value: string) => T
}

StorageProvider

Storage provider interface.

All storage providers must implement this interface.

interface StorageProvider {
  /**
   * Gets a value from storage.
   */
  get<T = unknown>(key: string): Promise<T | null>
  /**
   * Sets a value in storage.
   */
  set<T = unknown>(key: string, value: T): Promise<void>
  /**
   * Removes a value from storage.
   */
  remove(key: string): Promise<void>
  /**
   * Clears all values from storage.
   */
  clear(): Promise<void>
  /**
   * Gets all keys in storage.
   */
  keys(): Promise<string[]>
  /**
   * Gets multiple values from storage.
   */
  getMany?<T = unknown>(keys: string[]): Promise<Map<string, T | null>>
  /**
   * Sets multiple values in storage.
   */
  setMany?<T = unknown>(entries: Array<[string, T]>): Promise<void>
  /**
   * Removes multiple values from storage.
   */
  removeMany?(keys: string[]): Promise<void>
}

Functions

createAsyncStorageProvider(config)

Creates an AsyncStorage-based storage provider that implements the molecule StorageProvider interface.

Uses React Native's @react-native-async-storage/async-storage as the underlying storage engine. Supports key prefixing and custom serialization/deserialization.

function createAsyncStorageProvider(config?: AsyncStorageConfig): StorageProvider
  • config — Optional configuration for key prefix and serialization.

Returns: A StorageProvider backed by React Native AsyncStorage.

Constants

provider

Default AsyncStorage provider created with no prefix and JSON serialization.

const provider: StorageProvider

Core Interface

Implements @molecule/app-storage interface.

Bond Wiring

Setup function to register this provider with the core interface:

import { setProvider } from '@molecule/app-storage'
import { provider } from '@molecule/app-storage-async-storage'

export function setupStorageAsyncStorage(): void {
  setProvider(provider)
}

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-i18n ^1.0.1
  • @molecule/app-logger ^1.0.1
  • @molecule/app-storage ^1.0.1
  • @react-native-async-storage/async-storage ^2.0.0

Runtime Dependencies

  • @molecule/app-i18n

  • @molecule/app-logger

  • @molecule/app-storage

  • @react-native-async-storage/async-storage

  • Set a prefix in real apps. With no prefix, clear() calls AsyncStorage's global clear — wiping keys owned by OTHER libraries (navigation state, auth SDKs). A prefix scopes clear() and keys() to this app's entries.

  • get() returns null (with a logged warning) on any failure, including a value that fails to deserialize — a corrupted entry is indistinguishable from a missing one at the call site.

  • @react-native-async-storage/async-storage is a peer dependency loaded on first use — install it with npm install @react-native-async-storage/async-storage.

  • Values round-trip through JSON.stringify/JSON.parse by default (Dates become strings; undefined/functions are dropped) — pass custom serialize/deserialize for anything richer.