π v4.0.0 β Providerless, High-Performance Toasts
A complete rewrite. No provider, no Reanimated, no gesture-handler β just a tiny, tree-shakeable, WCAG 2.2 AA toast system built on
useSyncExternalStore.
β¨ Highlights
- πͺΆ Providerless API β Drop a single
<Toaster />anywhere in your tree. The<ToastProvider>wrapper is gone. - π‘ External store +
useSyncExternalStoreβ Per-toast subscriptions; sibling toasts no longer trigger sibling re-renders. - β‘ Microtask-batched dispatch β Bursts of
toast.show()collapse into a single render commit. - π¬ Native-driver
Animatedonly β Zero new peer deps. No Reanimated. No gesture-handler. - βΏ WCAG 2.2 AA β Reduce-motion (SC 2.3.3), 24Γ24 hit-targets (SC 2.5.8), live regions, full keyboard support.
- π Opt-in swipe-to-dismiss powered by core
PanResponder. - π§ TypeScript 6 strict β
erasableSyntaxOnly,noUncheckedSideEffectImports,isolatedModules, and friends.
π₯ Breaking Changes
β οΈ v4 is not a drop-in replacement for v3. Migration is straightforward but required.
- β
<ToastProvider>removed. Replace with<Toaster />mounted as a sibling near the root. - π
useToast()no longer requires a provider and returns a stable singleton API (no re-renders on toast changes). - π New imperative entry:
toastsingleton +configureToast(...)for code outside the React tree. - π§Ή Removed:
ToastContext, legacysizingutilities, and the oldfontSizeConfigshape β superseded by the unifiedToastConfig.
Before (v3)
<ToastProvider>
<App />
</ToastProvider>After (v4)
<>
<App />
<Toaster />
</>π New Features
- π―
<Toaster />β Lazy-mounted root component. Renders nothing until the first toast. - πͺ
useToast()β Ergonomic hook returning the full toast API (success,error,info,warning,show,dismiss,clear). - π°οΈ
toastsingleton β Call from anywhere (Redux middleware, API clients, error boundaries) β no React tree required. - βοΈ
configureToast(config)β Global defaults: position, duration, max visible, overflow strategy (evict/queue), haptics, animations, styling. - π§±
maxVisible+ overflow strategies β Cap visible toasts and chooseevict(drop oldest) orqueue(hold extras until a slot frees). - βΏ
useReducedMotion()β Public hook exposing the user's reduce-motion preference. - π¨ Per-toast overrides β
duration,style,textStyle,onPress,haptic, and accessibility props per call. - π Swipe-to-dismiss β Opt-in via config; built on
PanResponder, no extra deps. - π§ͺ 159 unit + integration tests β Full coverage across store, hooks, components, utils, and a11y.
π Improvements
- ποΈ Single source of truth for timers β
toastStoreexclusively owns auto-dismiss; the animation hook subscribes viaregisterDismissHandlerso exit animations always play before removal. - π§― Correct overflow eviction β Bursts that exceed
maxVisibleby more than one now evict every excess message in a single pass. - π§Ή Dismiss handler cleanup β
remove()andclear()always free their handler entries; no leaks on rapid show/dismiss cycles. - π§· Pinned RN preset versions β
@react-native/babel-preset@~0.83.6and@react-native/jest-preset@~0.85.2to prevent surprise majors. - π A11y hint always advertises tap-to-dismiss β independent of whether
onPressis set. - π White-screen bug on rapid toggles fixed.
- π Quick-tap dismissal reliably works at any animation phase.
- ποΈ
erasableSyntaxOnly+isolatedModulesfor cleaner per-file compilation and tooling parity.
π¦ Bundle & Deps
- πͺΆ Zero new peer dependencies β same install footprint as v3.
- π³
"sideEffects": falseβ bundlers strip every export you don't import. - 𧬠Dual ESM build via
react-native-builder-bob(module + typescript outputs).
π Documentation
- π README rewritten β new Quick Start, hook-first guidance, a11y guide, and full config reference.
- π§ Rich JSDoc β IDE hover-docs on every public symbol (
Toaster,useToast,toast,configureToast, all types). - π§© Migration guide for v3 β v4.
π Migration in 30 Seconds
- import { ToastProvider, useToast } from 'react-native-rooster';
+ import { Toaster, useToast } from 'react-native-rooster';
export default function App() {
return (
- <ToastProvider>
<RootNavigator />
- </ToastProvider>
+ <Toaster />
);
}The useToast() API surface is unchanged β your existing call sites (addToast, success, error, etc.) keep working.
π Thanks
Thanks to everyone who tested pre-releases, filed issues, and reviewed #108. Enjoy v4! π
Full Changelog: v3.2.5...v4.0.0