@fluixi/storage

中文文档
1.0.0-alpha.108发布于 2026/11/07MITTypeScriptESM + CJS近 30 天下载 5860

A universal storage abstraction: one typed API across browser, SSR, server and custom environments, with adapters, namespaces, expiry and versioned entries.

原始使用文档

@fluixi/storage

One typed key/value API over any backend: memory, localStorage, sessionStorage, cookies, a request, or your own. No dependency on the rest of Fluixi.

import { createStorage } from '@fluixi/storage';
import { localStorageAdapter } from '@fluixi/storage/browser';

const prefs = createStorage<{ theme: 'light' | 'dark' }>({ adapter: localStorageAdapter(), namespace: 'app' });

prefs.set('theme', 'dark', { ttl: 30 * 24 * 3600_000 });
prefs.get('theme'); // 'dark' | null
  • Adapters: memoryStorage (.), localStorageAdapter, sessionStorageAdapter and documentCookieAdapter (./browser), cookieStorage and requestStorage (./server), or your own.
  • Values: namespaces, expiry, versions and migrations, a strict JSON serializer that refuses what JSON would silently change.
  • Management: search, entries, prune, usage, update, getOrSet, snapshot, restore, copyStorage.
  • Changes: subscribe, across every storage over the same adapter and across tabs.
  • Encryption: per item and opt in, AES-256-GCM through Web Crypto, with a key provider.
  • Errors: one StorageError family with stable codes.

In a Fluixi app, useStorage, persisted and the theme helpers in @fluixi/core build on it.

Documentation: Storage and Storage in an app.

版本与发布记录

@fluixi/storage 共发布 16 个版本,首次发布于 2026/10/02;过去 12 个月发布了 16 个版本。

版本发布日期距今
1.0.0-alpha.108latest2026/11/078 天前
1.0.0-alpha.1072026/11/0511 天前
1.0.0-alpha.1062026/11/0213 天前
1.0.0-alpha.1052026/11/0115 天前
1.0.0-alpha.1042026/11/0115 天前
1.0.0-alpha.1032026/10/2620 天前

关于 @fluixi/storage 的常见问题

@fluixi/storage 是什么?

A universal storage abstraction: one typed API across browser, SSR, server and custom environments, with adapters, namespaces, expiry and versioned entries.

如何安装 @fluixi/storage?

在项目目录运行 npm install @fluixi/storage,或使用 pnpm add / yarn add / bun add。

@fluixi/storage 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fluixi/storage 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@fluixi/storage 可以商用吗?

@fluixi/storage 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fluixi/storage 的下载量有多少?

根据 npm 官方下载统计,@fluixi/storage 在 2026/10/15 – 2026/11/13 这 30 天内被下载 5,860 次,日均约 195 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fluixi/storage 还在维护吗?

最新版本 1.0.0-alpha.108 发布于 2026/11/07(8 天前);至今共发布 16 个版本,其中过去 12 个月发布了 16 个;首次发布于 2026/10/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。