StunkStunk
Getting Started

Changelog

A history of Stunk releases, API changes, and what's coming next.

Stunk follows semantic versioning. Minor and patch releases are fully backward-compatible. Breaking changes only happen in major versions.


v3.0.0 — alpha.2 (Current)

Alpha release. Bundle size: 3.32kB gzipped (core + React + Query).

v3 is in active development. APIs are stable but may change before the final release. For production use, see v2.8.1.

What's new in v3

Core (stunk)

  • peek() — read a chunk value without registering it as a tracked dependency
  • strict mode on ChunkConfig — throws or warns on unknown keys in set() in development
  • null is now a valid chunk value (undefined still forbidden)
  • ReadOnlyChunk<T>derive() now returns a proper read-only type at the TypeScript level
  • trackDependencies exported — for building custom reactive primitives
  • validateObjectShape improved — no longer warns on undefined → T or T → null transitions

Computed (redesigned)

  • Auto-tracks dependencies via .get() calls — no dependency arrays needed
  • Lazy evaluation with eager recompute when subscribers are active
  • isDirty() and recompute() for manual control
  • peek() inside computed() reads without tracking
  • Diamond dependency pattern handled correctly — subscribers notified once
// v2
const total = computed([price, quantity], (p, q) => p * q);

// v3
const total = computed(() => price.get() * quantity.get());

Query — new subpath stunk/query

  • asyncChunk — reactive async state with loading, error, data, lastFetched
  • infiniteAsyncChunk — accumulate-mode pagination for infinite scroll
  • combineAsyncChunks — unified loading/error/data across multiple async chunks
  • key option — request deduplication, concurrent calls share one in-flight request
  • keepPreviousData + isPlaceholderData — no UI flicker on param changes
  • onSuccess / onError callbacks
  • enabled as boolean or () => boolean — dynamic disabling
  • setParams with null clearing individual keys, clearParams() to wipe all
  • refetchOnWindowFocus, refetchInterval, staleTime, cacheTime
  • forceCleanup() + ref-counted cleanup()
  • Full pagination — nextPage, prevPage, goToPage, resetPagination
  • SSR-safe — all window access guarded

Middleware (stunk/middleware)

  • history (renamed from withHistory) — reset() now clears the history stack
  • skipDuplicates: true — strict equality only; 'shallow' — shallow equality for objects
  • persist (renamed from withPersistence) — clearStorage() added, onError called on type mismatches, array vs object type mismatch detection

React (stunk/react)

  • useAsyncChunk — rewritten: single effect, Rules of Hooks compliant, exposes isPlaceholderData and clearParams
  • useInfiniteAsyncChunk — stable IntersectionObserver, SSR-safe, correct isFetchingMore
  • useDerive, useComputed, useChunkProperty, useChunkValues — removed (use useChunkValue(computed(...)) instead)

Breaking changes from v2

Changev2v3
computed() APIcomputed([deps], fn)computed(() => fn)
withHistoryimport { withHistory }import { history }
withPersistenceimport { withPersistence }import { persist }
asyncChunk importstunkstunk/query
useDerive / useComputedavailableremoved
subscribe fires on subscribeyesno — only on change
null as chunk valueforbiddenallowed

v2.8.1 — Stable

Latest stable release. Bundle size: 2.95kB gzipped (core + React).

What's in v2

Core (stunk)

  • chunk() — atomic state primitive with get(), set(), reset(), destroy(), subscribe(), derive()
  • computed() — derive state from multiple chunks with dependency arrays and isDirty() tracking
  • select() — read-only derived chunk with optional shallow equality (useShallowEqual)
  • asyncChunk() — async state with built-in loading, error, data, and reload
  • infiniteAsyncChunk() — paginated / infinite-scroll async state
  • batch() — group multiple state updates into a single render cycle

Middleware (stunk/middleware)

  • logger — logs every set() call
  • withHistory() — undo/redo history (undo, redo, canUndo, canRedo, getHistory, clearHistory, maxHistory)
  • withPersistence() — localStorage persistence with custom serialize/deserialize
  • nonNegativeValidator — throws if a numeric value goes below zero

React (stunk/react)

  • useChunk — read and write a chunk reactively
  • useChunkValue — read-only subscription
  • useDerive — derive a value from a single chunk
  • useComputed — compute a value from multiple chunks
  • useAsyncChunk — async state hook
  • useInfiniteAsyncChunk — infinite scroll hook

v1 → v2 Migration

set() and update() merged

// v1
count.set(10);
count.update((n) => n + 1);

// v2+
count.set(10);
count.set((n) => n + 1); // update() removed

Release History

VersionStatusHighlights
3.0.0-alpha🚧 AlphaComputed redesign, stunk/query, strict mode, null values
2.8.1✅ StableLatest stable, 2.95kB gzipped
2.x✅ StableFull React integration, async, middleware, time travel
1.x⚠️ DeprecatedEarly API, no longer supported

On this page