@buoy-gg/time-machine

中文文档
7.0.87发布于 2026/11/07TypeScriptESM + CJS近 30 天下载 5047

Time Machine - snapshot & restore app state (storage, redux, zustand, jotai, react-query) for React Native DevTools

原始使用文档
文档目录7 节
  1. Install
  2. Account setup
  3. Use a restore point
  4. Restore limits
  5. API
  6. Desktop and MCP
  7. Web support (unreleased)

@buoy-gg/time-machine

Save and restore supported client state while testing a React Native app. A restore point can include registered storage, Redux, Zustand, Jotai, and the React Query cache. Review the restore preview before applying changes.

Install

npm install @buoy-gg/core @buoy-gg/time-machine

Account setup

Start in a development build. You need a Free or Pro Buoy account. Sign in from your app's folder:

npx --package=@buoy-gg/core buoy login

Your browser opens buoy.gg. Click Allow. The CLI then writes a dev token. It works in dev builds for 30 days.

On Expo, the token goes in .env.development.local. Buoy reads it by itself in dev builds. You can also pass it in yourself:

import { Buoy } from "@buoy-gg/core";

Buoy.init({ licenseKey: process.env.EXPO_PUBLIC_BUOY_KEY });

On React Native CLI, the token goes in .env.local as BUOY_KEY. React Native does not load that file by itself. Pass the token in with your app's own env setup. Keep the menu inside the providers used by your app. Restart the development server after installing packages. See the Quick Start for the complete root component.

Use a restore point

Mount FloatingDevTools in your app. Buoy discovers this package. Install and configure the source tools for the state you want to capture: Storage, Redux, Zustand, Jotai, or React Query.

  1. Put the app into a recognizable test state and capture a named restore point.
  2. Change a disposable value through the app.
  3. Open the restore preview. Check additions, removals, overwrites, skipped items, and selected sources.
  4. Restore, then read the value from the app and inspect the per-source results.

To repeat one restore many times, tap Action bar in the tool header or swipe a restore point and choose Bar. The tool minimizes and a floating strip stays over the app with one restore point armed: tap to restore it (long press for state only, without changing screens), + to name, capture and arm a new point, the chevron beside the name picks another. Each restore from the strip saves a "Before last restore" copy first and offers Undo for ten seconds. The strip's picker has a "Reload the app after restoring" switch for screens that read their state from storage only on mount (a cart kept in a React context, for example): a live restore cannot reach useState, a reload can. The strip returns after a reload and can be dragged or hidden at the screen edge.

Live restore applies supported state in place. Restore + reload writes persisted storage and reloads JavaScript so the app can initialize from that storage. Optional Expo Router URL restoration does not recreate the entire navigation back stack.

Each tile in the Sources strip is a switch. A source switched off is left out of every capture and restore, so a store the app cannot survive having replaced (a Zustand store holding live handles, for example) can stay untouched while the rest of the state round-trips.

Restore limits

Restoring can remove keys absent from the snapshot. Exclude values you need to preserve in the preview. Read-only or unsupported values are skipped and reported. SecureStore and MMKV require the same registered keys and instances as the Storage tool.

Backend changes, component-local useState, and in-flight requests are not restored. A restored cart or session remains subject to backend validation. Redux needs a supported full-state restore integration; writable Jotai atoms can be restored, while read-only atoms recompute. React Query mutation history is not replayed.

API

For explicit registration, use the exported createTimeMachineTool or timeMachineToolPreset. Advanced integrations can use timeMachineStore, RestoreOptions, and RestoreOutcome.

See the Time Machine guide for source-specific behavior, persistent exclusions, and restore results.

Desktop and MCP

React Native connections require @buoy-gg/external-sync. Follow the Desktop connection guide, sign in to Desktop separately, and confirm the selected device. MCP uses the sign-in from buoy login on your computer. Free has the basic MCP. Reading this tool from the MCP needs Pro.

Device data can travel over your LAN to the configured broker. Account validation makes network requests. See Telemetry for data-flow details.

Web support (unreleased)

In dev builds, a saved bar opens on web boot.

Register this package’s /web namespace in FloatingDevTools modules to use its shared panels and actions in a browser app. The browser build is available in this checkout and has not been published yet. See the web setup guide for registration, dependencies, and browser boundaries.

版本与发布记录

@buoy-gg/time-machine 共发布 70 个版本,首次发布于 2026/08/07;过去 12 个月发布了 70 个版本。

版本发布日期距今
7.0.87latest2026/11/071 天前
7.0.862026/11/062 天前
7.0.852026/11/053 天前
7.0.842026/11/035 天前
7.0.832026/11/035 天前
7.0.822026/11/036 天前

关于 @buoy-gg/time-machine 的常见问题

@buoy-gg/time-machine 是什么?

Time Machine - snapshot & restore app state (storage, redux, zustand, jotai, react-query) for React Native DevTools

如何安装 @buoy-gg/time-machine?

在项目目录运行 npm install @buoy-gg/time-machine,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(*)、@buoy-gg/license(7.0.87)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@buoy-gg/time-machine 支持 TypeScript 吗?

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

@buoy-gg/time-machine 支持 ESM 还是 CommonJS?

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

@buoy-gg/time-machine 可以商用吗?

@buoy-gg/time-machine 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@buoy-gg/time-machine 的下载量有多少?

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

@buoy-gg/time-machine 还在维护吗?

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