🚨 Breaking Changes
- all:
isSupported
becomesRef<boolean>
instead ofboolean
for SSR compatibility - by @okxiaoliang4 in #1800 - all: Rename function options type with consistant
Use
prefix, huge thanks to @okxiaoliang4! (this should not affect most of the usage case, unless you are importing those types directly)-
All Changes
- useSpeechSynthesis: Rename type
Status
toUseSpeechSynthesisStatus
- by @antfu (db61f) - onKeyStroke: Rename type
KeyStrokeOptions
toOnKeyStrokeOptions
- by @okxiaoliang4 in #1807 - useAsyncState: Rename type
AsyncStateOptions
toUseAsyncStateOptions
- by @okxiaoliang4 in #1809 - useClipboard: Rename type
ClipboardOptions
toUseClipboardOptions
andClipboardReturn
toUseClipboardReturn
- by @okxiaoliang4 in #1861 - useElementVisibility: Rename type
VisibilityScrollTargetOptions
toUseElementVisibilityOptions
- by @okxiaoliang4 in #1863 - useEventSource: Return type should be
UseEventSourceReturn
- by @okxiaoliang4 in #1864 - useFavicon: Rename type
FaviconOptions
toUseFaviconOptions
- by @okxiaoliang4 in #1865 - useFocusWithin: Rename type
FocusWithinReturn
toUseFocusWithinReturn
- by @okxiaoliang4 in #1866 - useGeolocation: Rename type
GeolocationOptions
toUseGeolocationOptions
- by @okxiaoliang4 in #1868 - useIdle: Rename type
IdleOptions
toUseIdleOptions
- by @okxiaoliang4 in #1869 - useIntersectionObserver: Rename type
IntersectionObserverOptions
toUseIntersectionObserverOptions
- by @okxiaoliang4 in #1870 - useJwt: Rename type
JwtOptions
toUseJwtOptions
andJwtResult
toUseJwtReturn
- by @okxiaoliang4 in #1899 - useKeyModifier: Rename type
ModifierOptions
toUseModifierOptions
- by @okxiaoliang4 in #1871 - useMagicKeys: Rename type
MagicKeys
toUseMagicKeysReturn
- by @okxiaoliang4 in #1873 - useMemoize: Rename type
UseMemoizedFn
toUseMemoizeReturn
and new typeUseMemoizeOptions
- by @okxiaoliang4 in #1872 - useMemory: Rename type
MemoryOptions
toUseMemoryOptions
- by @okxiaoliang4 in #1605 - useMouse: Rename type
MouseOptions
toUseMouseOptions
- by @okxiaoliang4 in #1877 - useMutationObserver: Rename type
MutationObserverOptions
toUseMutationObserverOptions
- by @okxiaoliang4 in #1884 - useParallax: Rename type
ParallaxOptions
toUseParallaxOptions
andParallaxReturn
toUseParallaxReturn
- by @okxiaoliang4 in #1885 - usePointerSwipe: Rename type
PointerSwipeOptions
toUsePointerSwipeOptions
andPointerSwipeReturn
toUsePointerSwipeReturn
- by @okxiaoliang4 in #1886 - useRTDB: Rename type
RTDBOptions
toUseRTDBOptions
- by @okxiaoliang4 in #1901 - useRafFn: Rename type
RafFnOptions
toUseRafFnOptions
- by @okxiaoliang4 in #1887 - useResizeObserver: Rename type
ResizeObserverOptions
toUseResizeObserverOptions
- by @okxiaoliang4 in #1862 - useShare: Rename type
ShareOptions
toUseShareOptions
- by @okxiaoliang4 in #1888 - useSpeechRecognition: Rename type
SpeechRecognitionOptions
toUseSpeechRecognitionOptions
- by @okxiaoliang4 in #1889 - useSpeechSynthesis: Rename type
SpeechSynthesisOptions
toUseSpeechSynthesisOptions
- by @okxiaoliang4 in #1890 - useSpeechSynthesis: Remove
voiceInfo
, allowvoice
as ref - by @sibbng in #1882 - useStorage: Rename type
StorageOptions
toUseStorageOptions
- by @okxiaoliang4 in #1867 - useStorageAsync: Rename type
StorageAsyncOptions
toUseStorageAsyncOptions
- by @okxiaoliang4 in #1883 - useSwipe: Rename type
SwipeOptions
toUseSwipeOptions
andSwipeReturn
toUseSwipeReturn
- by @okxiaoliang4 in #1891 - useTimestamp: Rename type
TimestampOptions
toUseTimestampOptions
- by @okxiaoliang4 in #1892 - useTransition: Rename type
TransitionOptions
toUseTransitionOptions
- by @okxiaoliang4 in #1893 - useVModel: Rename type
VModelOptions
toUseVModelOptions
- by @okxiaoliang4 in #1894 - useWebSocket: Rename type
WebSocketOptions
toUseWebSocketOptions
andWebSocketResult
toUseWebSocketReturn
- by @okxiaoliang4 in #1895 - useWebWorkerFn: Rename type
WebWorkerOptions
toUseWebWorkerOptions
- by @okxiaoliang4 in #1896 - useWindowSize: Rename type
WindowSizeOptions
toUseWindowSizeOptions
- by @okxiaoliang4 in #1897 - useInterval: Rename type
IntervalOptions
toUseIntervalOptions
- by @okxiaoliang4 in #1945 - useIntervalFn: Rename type
IntervalFnOptions
toUseIntervalFnOptions
- by @okxiaoliang4 in #1943 - useTimeoutFn,useTimeout: Rename type
TimeoutOptions
toUseTimeoutOptions
andTimeoutFnOptions
toUseTimeoutFnOptions
- by @okxiaoliang4 in #1944
- useSpeechSynthesis: Rename type
-
- firebase: Support firebase 9 modular - by @antfu (9c65f)
- math: Move
logicAnd
,logicOr
,logicNot
,useClamp
to@vueuse/math
- by @antfu in #1794, #1810 - reactify: Enable support for reactive getter by default - by @antfu in #1860
- useThrottleFn:
trailing
option should befalse
by default - by @webfansplz and @antfu in #1687 - useMagicKeys: Store
key
instead ofkeyCode
incurrent
- by @wvffle in #1506
🚀 Features
-
all: Support reactive getter as argument - in #1768
This introduces a new convention of passing reactive getters as arguments. Previously, many of VueUse functions supported a convention to accept optional Ref as arguments (
MaybeRef<T>
) to make the reactivity connections. For example:// pass plain value const title = useTitle('foo') // changes title to 'foo' // pass a ref const myTitle = ref('foo') useTitle(myTitle) // changes title to 'foo' // reactive triggers the update myTitle.value = 'bar' // changes title to 'bar'
Since v9.0, most of the VueUse function also accepts a getter function similar to
computed
or the watch source ofwatch
to provide better flexibility.// before const title = computed(() => `${foo.value} | template`) useTitle(title) // with 9.0 useTitle(() => `${foo.value} | template`)
It also works great with Reactivity Transform.
// before const title = $('foo') useTitle($$(title)) // you need to use $$() to preserve the reactive // with 9.0 const title = $('foo') useTitle(() => title) // you can use a getter function just like `watch`
-
math: New
@vueuse/math
package- useAbs: New function - by @LittleSound and @antfu in #1825
- useCeil: New function - by @webfansplz in #1818
- useFloor: New function - by @webfansplz in #1817
- useMath: New function - by @antfu in #1935
- useMax: New function - by @FrankFang and @antfu in #1829
- useMin: New function - by @antfu in #1934
- useRound: New function - by @webfansplz in #1820
- useSum: New function - by @holazz in #1837
- useTrunc: New function - by @hanpei and @antfu in #1838
- useAverage: New function - by @colgin and @antfu in #1826
-
New Array-related utilities
- useArrayEvery: New function - by @huynl-96 in #1915
- useArrayFilter: New function - by @huynl-96 in #1905
- useArrayFind: New function - by @yjl9903 and @antfu in #1875
- useArrayJoin: New function - by @huynl-96 in #1904
- useArrayMap: New function - by @huynl-96 and @antfu in #1908
- useArrayReduce: New function - by @yjl9903 and @antfu in #1919
- useArraySome: New function - by @huynl-96 in #1916
- useArrayFindIndex: New function - by @huynl-96 in #1973
-
syncRef: Support custom transforms - by @chaii3 and @antfu in #1968
-
useAsyncState: Add
throwError
option - by @TuiMao233 and @antfu in #1975 -
useStorage:
mergeDefaults
option - by @webfansplz and @antfu in #1957 -
useTextDirection: New function - by @iChengbo and @antfu in #1678
🐞 Bug Fixes
- nuxt: Support import submodules for
@vueuse/integrations
- by @antfu (18ba0) - onClickOutside: Fix handler type - by @sibbng in #1961
- useOffsetPagination: Incorrectly
currentPageSize
value - by @webfansplz in #1949 - useSpeechSynthesis: Remove duplicated
onend
, fix demo - by @sibbng in #1941 - useWebSocket: Set initial status as
CLOSED
- by @chaii3 in #1960 - useNProgress: Improve SSR support - by @webfansplz in #1990