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

@daltonr/pathwrite-store

v0.12.0

Published

Persistence adapters for PathEngine — LocalStorageStore (browser), AsyncStorageStore (React Native / any async key-value store), and HttpStore (REST API)

Downloads

63

Readme

@daltonr/pathwrite-store

HTTP, localStorage, and AsyncStorage persistence for Pathwrite.

Installation

npm install @daltonr/pathwrite-store

AsyncStorageStore additionally requires @react-native-async-storage/async-storage, which is not installed automatically.

Quick start

import { PathEngine } from "@daltonr/pathwrite-core";
import { HttpStore, persistence, restoreOrStart } from "@daltonr/pathwrite-store";

const store = new HttpStore({
  baseUrl: "/api/wizard",
  headers: { Authorization: `Bearer ${token}` },
  // Expects these three endpoints on your backend:
  //   PUT    /api/wizard/state/{key}   — save state (body: SerializedPathState)
  //   GET    /api/wizard/state/{key}   — load state (return 404 when not found)
  //   DELETE /api/wizard/state/{key}   — delete state on completion
});

const key = `user:${userId}:onboarding`;

const { engine, restored } = await restoreOrStart({
  store,
  key,
  path: onboardingWizard,
  initialData: { name: "", email: "" },
  observers: [
    persistence({ store, key, strategy: "onNext" }),
  ],
});

// Pass the engine to any framework adapter
// e.g. const { snapshot, next } = usePath({ engine });

if (restored) {
  console.log("Resuming from saved progress.");
}

Stores

| Store | Import | Use for | |---|---|---| | HttpStore | @daltonr/pathwrite-store | REST API backend (browser or Node). | | LocalStorageStore | @daltonr/pathwrite-store | Browser localStorage or sessionStorage. Falls back to in-memory in Node/test environments. | | AsyncStorageStore | @daltonr/pathwrite-store | React Native. Requires @react-native-async-storage/async-storage as a peer dependency. |

All three implement the PathStore interface from @daltonr/pathwrite-core (save, load, delete) and are interchangeable as far as persistence() and restoreOrStart() are concerned.

Save strategies

Pass strategy to persistence() to control when saves fire.

| Strategy | When it saves | API calls (5 keystrokes + Next) | |---|---|---| | "onNext" (default) | After next() navigates to a new step | 1 | | "onEveryChange" | Every settled stateChanged event (add debounceMs for text inputs) | 6 (or 2 with debounceMs: 500) | | "onSubPathComplete" | When a sub-path finishes and the parent path resumes | varies | | "onComplete" | When the path completes; does not delete the record afterward | 0 mid-flow, 1 at end | | "manual" | Never — call store.save(key, engine.exportState()!) yourself | 0 |

restoreOrStart()

restoreOrStart() handles the standard load/restore-or-start pattern in a single call. It tries store.load(key); if a saved state is found it reconstructs the engine at the saved step via PathEngine.fromState(); if nothing is found it creates a fresh engine and calls engine.start(path, initialData). Observers are wired before the first event in both cases, so the persistence observer never misses a state transition.

const { engine, restored } = await restoreOrStart({
  store,          // any PathStore
  key,            // string session key, e.g. "user:123:signup"
  path,           // PathDefinition for the wizard
  initialData,    // used only when starting fresh (not on restore)
  observers,      // PathObserver[] — wired before the first event
  pathDefinitions // optional: required when the path uses sub-paths
});

engine is a plain PathEngine ready to pass to any framework adapter. restored is true when a saved session was found. When the path later completes, the persistence observer automatically calls store.delete(key) so a returning user starts fresh.

Further reading