Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/docs/content/guides/idb-react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ npm i @stainless-code/persist @tanstack/store react idb-keyval

**Store module** — `createIdbStorage` runs structured-clone mode: `Set` / `Map` / `Date` round-trip natively, no codec. The persist + hydration signal live at module scope for an app-lifetime singleton store.

```ts
```ts ts2js
// prefs-store.ts
import { Store } from "@tanstack/store";
import { toHydrationSignal } from "@stainless-code/persist";
Expand Down Expand Up @@ -49,7 +49,7 @@ export function PrefsPanel() {

**Non-singleton stores** (a per-route filter store, a per-instance draft editor) must create the persist in `useEffect` and tear it down on unmount — `destroy()` detaches the source subscription, removes the cross-tab listener, unregisters from any registry, and flushes any pending throttled write:

```tsx
```tsx ts2js
useEffect(() => {
const persist = persistStore(filtersStore, {
name: `app:filters:${id}`,
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/content/recipes/react-native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Pick by sync-vs-async (does it gate UI?) and threat model. All three are string-

## AsyncStorage

```ts
```ts ts2js
import { createAsyncStorage } from "@stainless-code/persist/backends/async-storage";
import { persistStore } from "@stainless-code/persist/sources/zustand";
import { toHydrationSignal } from "@stainless-code/persist";
Expand All @@ -31,7 +31,7 @@ const { hydrated } = useHydrated(prefsHydration);

## MMKV

```ts
```ts ts2js
import { createMmkvStorage } from "@stainless-code/persist/backends/mmkv";
import { persistStore } from "@stainless-code/persist/sources/zustand";

Expand All @@ -42,7 +42,7 @@ persistStore(usePrefs, { name: "app:prefs:v1", storage });

## Expo Secure Store

```ts
```ts ts2js
import { createSecureStoreStorage } from "@stainless-code/persist/backends/secure-store";
import { persistStore } from "@stainless-code/persist/sources/zustand";
import { toHydrationSignal } from "@stainless-code/persist";
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/content/recipes/standard-schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ search:

Invalid prefs must not survive a refresh. Pass any sync `~standard` schema — Persist validates on write and on read; `clearCorruptOnFailure` attempts to remove the key.

```ts
```ts ts2js
import { z } from "zod";
// or: import * as v from "valibot"; // any ~standard schema works
import { createStandardSchemaStorage } from "@stainless-code/persist/codecs/standard-schema";
Expand Down Expand Up @@ -35,7 +35,7 @@ persistStore(usePrefs, {

`createStandardSchemaStorage` is JSON sugar over `withStandardSchema`. Wraps are the primitive — compose after any `PersistStorage` (don't stack wrap + `standardSchemaCodec`; that double-validates):

```ts
```ts ts2js
import { createIdbStorage } from "@stainless-code/persist/backends/idb";
import { withStandardSchema } from "@stainless-code/persist/codecs/standard-schema";

Expand All @@ -48,7 +48,7 @@ const storage = withStandardSchema(createIdbStorage<Prefs>()!, prefs, {

`~standard.validate` may return a `Promise` (Yup, async refine). Codecs stay sync — use the async wrap / factory:

```ts
```ts ts2js
import { createStandardSchemaStorageAsync } from "@stainless-code/persist/codecs/standard-schema";

const storage = createStandardSchemaStorageAsync(() => localStorage, yupSchema)!;
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"validate": "blume validate"
},
"dependencies": {
"blume": "1.4.2"
"blume": "1.6.0"
}
}
4 changes: 4 additions & 0 deletions apps/docs/public/icon-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading