[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M782C6F40DEDVFYY702FFRXE":3,"skill-same:01M782C6F40DEDVFYY702FFRXE":56},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":39,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M782C6F40DEDVFYY702FFRXE","persist-zustand",null,"Persist a zustand StoreApi with @stainless-code\u002Fpersist (persistStore). Use when wiring zustand to localStorage\u002FsessionStorage\u002FIndexedDB, replacing zustand\u002Fmiddleware persist, or choosing between persistStore and persistSource for a zustand store.","stainless-code\u002Fpersist","stainless-code","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F188862219?v=4","01M7826VYMCF2NTQWQZRWQ454T","STAINLESS CODE","01M7826VZKNC149Y9ZNK0F93N7",5,"MIT","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fpersist-zustand\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: persist-zustand\ndescription: Persist a zustand StoreApi with @stainless-code\u002Fpersist (persistStore). Use when wiring zustand to localStorage\u002FsessionStorage\u002FIndexedDB, replacing zustand\u002Fmiddleware persist, or choosing between persistStore and persistSource for a zustand store.\nlicense: MIT\nmetadata:\n  type: composition\n  library: \"@stainless-code\u002Fpersist\"\n  library_version: \"0.4.1\"\n  framework: \"zustand\"\nsources:\n  - stainless-code\u002Fpersist:README.md\n  - stainless-code\u002Fpersist:docs\u002Farchitecture.md\n  - stainless-code\u002Fpersist:src\u002Fadapters\u002Fsources\u002Fzustand.ts\n---\n\n# Persisting zustand\n\n`@stainless-code\u002Fpersist\u002Fsources\u002Fzustand` maps zustand's `StoreApi` (`getState` \u002F `setState` \u002F `subscribe`) onto `persistSource`. Prefer this over zustand's built-in `persist` middleware when you want Persist's hydration gate, trailing throttle, cross-tab helpers, or the same storage\u002Fcodec stack as other Persist adapters.\n\n## When to use this skill\n\n- You have a zustand store (`create(...)` \u002F `StoreApi`) and want it to survive reload.\n- You're migrating off `zustand\u002Fmiddleware`'s `persist`.\n- You need async-backend hydration gating (`useHydrated`) shared with other Persist sources.\n\nOther sources → matching `persist-*` skill. UI gate → `*-persist`.\n\n## Install\n\n```bash\nbun add @stainless-code\u002Fpersist zustand\n# only when you use a codec that needs it:\nbun add seroval\n```\n\n`zustand` is an optional peer of the `\u002Fsources\u002Fzustand` subpath — importing the subpath is the dep opt-in.\n\n## Minimal wiring\n\n```ts\nimport { create } from \"zustand\";\nimport { createJSONStorage } from \"@stainless-code\u002Fpersist\";\nimport { persistStore } from \"@stainless-code\u002Fpersist\u002Fsources\u002Fzustand\";\n\nconst usePrefs = create(() => ({ theme: \"light\" as const }));\nconst persist = persistStore(usePrefs, {\n  name: \"app:prefs:v1\",\n  storage: createJSONStorage(() => localStorage),\n});\n```\n\nPass the store API (`usePrefs`), not a hook call. `persist` is a `PersistApi` — keep it for `rehydrate()` \u002F `destroy()` \u002F `onHydrate` \u002F `clearStorage()`.\n\n## vs zustand\u002Fmiddleware `persist`\n\n| Concern            | zustand `persist`    | `@stainless-code\u002Fpersist`                            |\n| ------------------ | -------------------- | ---------------------------------------------------- |\n| Hydration gate     | library-specific     | built-in; pair with `useHydrated` for async backends |\n| Storage \u002F codecs   | JSON-centric helpers | `createStorage` + json \u002F seroval \u002F identity \u002F custom |\n| Cross-tab          | optional listeners   | `crossTab` + `crossTabEventTarget` for IDB           |\n| Multi-library apps | zustand-only         | same Options \u002F `PersistApi` across source adapters   |\n\nKeep zustand middleware for zustand-only apps that already depend on its persist API. Switch when you want one persist stack across stores.\n\n## Hydration gate\n\nWrites are gated until hydration settles (same as other Persist sources). Sync backends settle in a microtask; IndexedDB needs a UI gate:\n\n```ts\nimport { toHydrationSignal } from \"@stainless-code\u002Fpersist\";\nimport { useHydrated } from \"@stainless-code\u002Fpersist\u002Fframeworks\u002Freact\";\n\nexport const prefsHydration = toHydrationSignal(persist);\nconst { hydrated } = useHydrated(prefsHydration);\n```\n\n## Teardown — required for non-singletons\n\n`persistStore` subscribes to the store. For route\u002Fcomponent-scoped stores, `destroy()` on unmount.\n\n```ts\nuseEffect(() => {\n  const persist = persistStore(store, opts);\n  return () => persist.destroy();\n}, [store]);\n```\n\n## Common mistakes\n\n- **Passing `usePrefs()` (state) instead of `usePrefs` (API).** The adapter needs `getState` \u002F `setState` \u002F `subscribe`.\n- **Stacking zustand `persist` middleware and this adapter.** Pick one write path.\n- **Gating writes manually before hydration.** The gate is built in.\n- **`identityCodec` with string-only backends.** Use `jsonCodec` \u002F `createJSONStorage` for `localStorage`; `identityCodec` is for structured-clone IDB.\n\n## API surface for this skill\n\n- `persistStore(store, options) → PersistApi` — `store: StoreApi\u003CTState>`\n- Options \u002F `PersistApi`: see skill `persist`.\n","# Persisting zustand\n\n`@stainless-code\u002Fpersist\u002Fsources\u002Fzustand` maps zustand's `StoreApi` (`getState` \u002F `setState` \u002F `subscribe`) onto `persistSource`. Prefer this over zustand's built-in `persist` middleware when you want Persist's hydration gate, trailing throttle, cross-tab helpers, or the same storage\u002Fcodec stack as other Persist adapters.\n\n## When to use this skill\n\n- You have a zustand store (`create(...)` \u002F `StoreApi`) and want it to survive reload.\n- You're migrating off `zustand\u002Fmiddleware`'s `persist`.\n- You need async-backend hydration gating (`useHydrated`) shared with other Persist sources.\n\nOther sources → matching `persist-*` skill. UI gate → `*-persist`.\n\n## Install\n\n```bash\nbun add @stainless-code\u002Fpersist zustand\n# only when you use a codec that needs it:\nbun add seroval\n```\n\n`zustand` is an optional peer of the `\u002Fsources\u002Fzustand` subpath — importing the subpath is the dep opt-in.\n\n## Minimal wiring\n\n```ts\nimport { create } from \"zustand\";\nimport { createJSONStorage } from \"@stainless-code\u002Fpersist\";\nimport { persistStore } from \"@stainless-code\u002Fpersist\u002Fsources\u002Fzustand\";\n\nconst usePrefs = create(() => ({ theme: \"light\" as const }));\nconst persist = persistStore(usePrefs, {\n  name: \"app:prefs:v1\",\n  storage: createJSONStorage(() => localStorage),\n});\n```\n\nPass the store API (`usePrefs`), not a hook call. `persist` is a `PersistApi` — keep it for `rehydrate()` \u002F `destroy()` \u002F `onHydrate` \u002F `clearStorage()`.\n\n## vs zustand\u002Fmiddleware `persist`\n\n| Concern            | zustand `persist`    | `@stainless-code\u002Fpersist`                            |\n| ------------------ | -------------------- | ---------------------------------------------------- |\n| Hydration gate     | library-specific     | built-in; pair with `useHydrated` for async backends |\n| Storage \u002F codecs   | JSON-centric helpers | `createStorage` + json \u002F seroval \u002F identity \u002F custom |\n| Cross-tab          | optional listeners   | `crossTab` + `crossTabEventTarget` for IDB           |\n| Multi-library apps | zustand-only         | same Options \u002F `PersistApi` across source adapters   |\n\nKeep zustand middleware for zustand-only apps that already depend on its persist API. Switch when you want one persist stack across stores.\n\n## Hydration gate\n\nWrites are gated until hydration settles (same as other Persist sources). Sync backends settle in a microtask; IndexedDB needs a UI gate:\n\n```ts\nimport { toHydrationSignal } from \"@stainless-code\u002Fpersist\";\nimport { useHydrated } from \"@stainless-code\u002Fpersist\u002Fframeworks\u002Freact\";\n\nexport const prefsHydration = toHydrationSignal(persist);\nconst { hydrated } = useHydrated(prefsHydration);\n```\n\n## Teardown — required for non-singletons\n\n`persistStore` subscribes to the store. For route\u002Fcomponent-scoped stores, `destroy()` on unmount.\n\n```ts\nuseEffect(() => {\n  const persist = persistStore(store, opts);\n  return () => persist.destroy();\n}, [store]);\n```\n\n## Common mistakes\n\n- **Passing `usePrefs()` (state) instead of `usePrefs` (API).** The adapter needs `getState` \u002F `setState` \u002F `subscribe`.\n- **Stacking zustand `persist` middleware and this adapter.** Pick one write path.\n- **Gating writes manually before hydration.** The gate is built in.\n- **`identityCodec` with string-only backends.** Use `jsonCodec` \u002F `createJSONStorage` for `localStorage`; `identityCodec` is for structured-clone IDB.\n\n## API surface for this skill\n\n- `persistStore(store, options) → PersistApi` — `store: StoreApi\u003CTState>`\n- Options \u002F `PersistApi`: see skill `persist`.\n",{"name":5,"license":15,"sources":24,"metadata":28,"description":7},[25,26,27],"stainless-code\u002Fpersist:README.md","stainless-code\u002Fpersist:docs\u002Farchitecture.md","stainless-code\u002Fpersist:src\u002Fadapters\u002Fsources\u002Fzustand.ts",{"type":29,"library":30,"framework":31,"library_version":32},"composition","@stainless-code\u002Fpersist","zustand","0.4.1","main","29ca2183c92cd13e04ce6c14fb431fd6993862cd","skills\u002Fpersist-zustand",0,"https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist","https:\u002F\u002Fgithub.com\u002Fstainless-code","https:\u002F\u002Fstainless-code.com\u002F","Open-source tooling for JS\u002FTS and AI agents.","2026-11-01 20:56:20",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add stainless-code\u002Fpersist --skill persist-zustand",{"tool":48,"command":49},"bunx","bunx skills add stainless-code\u002Fpersist --skill persist-zustand",{"tool":51,"command":52},"pnpm","pnpm dlx skills add stainless-code\u002Fpersist --skill persist-zustand","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fpersist-zustand\u002FSKILL.md",true,[],[57,64,71,78,85,92],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M782D4ZQGJPNT470FSKDB6A8","vue-persist","Gate Vue 3 UI on Persist hydration with useHydrated (shallowRef). Use in setup\u002FeffectScope when avoiding flash of default state on async backends.","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fvue-persist\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M782D1GJRWNQ3458F3H1FK2F","svelte-store-persist","Gate Svelte store-based UI on Persist hydration with hydratedStore (Readable). Use for Svelte 3–4 or Svelte 5 apps that still use stores; runes UI → svelte-persist.","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fsvelte-store-persist\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M782CWBTRWAQ52TBNQ8665CC","svelte-persist","Gate Svelte 5 runes UI on Persist hydration with hydratedRune (.current). Use for Svelte 5; for stores \u002F Svelte 3–4 use svelte-store-persist.","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fsvelte-persist\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M782CR8Z2V3SJW661RTMWY2F","solid-persist","Gate Solid UI on Persist hydration with useHydrated (Accessor). Use when avoiding flash of default state on async backends; read hydrated() in reactive scopes.","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fsolid-persist\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M782CJQGP7739WA9BS801HZP","react-persist","Gate React UI on Persist hydration with useHydrated + toHydrationSignal. Use when avoiding flash of default state on async backends (IndexedDB), SSR snapshot true, or wiring HydrationSignal into React 18\u002F19.","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Freact-persist\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M782CF96RMXCDETM5TF2JDRV","preact-persist","Gate Preact UI on Persist hydration with useHydrated (preact\u002Fcompat useSyncExternalStore). Use when avoiding flash of default state on async backends or wiring HydrationSignal into Preact.","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fpreact-persist\u002FSKILL.md",[],[]]