AGENT SKILL

persist-async-storage

Persist with React Native AsyncStorage via @stainless-code/persist/backends/async-storage. Use for RN string-wire JSON state; always gate with useHydrated.

License 许可
MIT
最近更新
2026-11-01
Stars
★ 5
Forks
0

01 前言 Front Matter

name
persist-async-storage
license
MIT
sources
[ "stainless-code/persist:src/adapters/backends/async-storage.ts" ]
metadata
{ "type": "composition", "library": "@stainless-code/persist", "framework": "@react-native-async-storage/async-storage", "library_version": "0.4.1" }
requires
[ "persist" ]
description
Persist with React Native AsyncStorage via @stainless-code/persist/backends/async-storage. Use for RN string-wire JSON state; always gate with useHydrated.

03 SKILL.md 正文

AsyncStorage backend

JSON via createJSONStorage under the hood. Fully async → useHydrated mandatory. Factory does not accept clearCorruptOnFailure — use createStorage(() => asyncStorageStateStorage(), jsonCodec(), opts) when you need it.

Install

bun add @stainless-code/persist @react-native-async-storage/async-storage

Peer: @react-native-async-storage/async-storage >=1.0.0.

Minimal wiring

import { createAsyncStorage } from "@stainless-code/persist/backends/async-storage";

const storage = createAsyncStorage<Prefs>()!;

Optional custom instance for namespacing: createAsyncStorage(myAsyncStorage).

Common mistakes

  • Treating hydrate as sync.
  • Expecting Set/Map/Date — use seroval compose or avoid.
  • Passing clearCorruptOnFailure to the factory.

API surface

  • createAsyncStorage(storage?) · asyncStorageStateStorage(storage?)

See also: persist-mmkv (sync RN).

04 同仓库更多 Skills