Error handling
This page only applies to the new
runtime - not the legacy
runtime.
Hook errors
The loading hooks return anerror instead of throwing. Check it alongside the loading state:
useRiveFilesetserrorwhen the file can’t be loaded or decoded.useViewModelInstancesetserrorwhen the requested view model, artboard, or instance doesn’t exist. Withrequired: true, it throws instead, so you can handle it with an error boundary.- The property hooks (
useRiveNumber,useRiveTrigger, and so on) seterrorwhen the property path can’t be found or read.
Imperative APIs
Wrap Rive operations in try/catch blocks to handle errors. For example, when loading a file:View-based errors
Use theonError callback prop to handle errors during view configuration or runtime operations:
Error types
The following error types may occur during view operations:
In
0.4.x, you can use these error types to provide specific error handling:
If no
onError handler is provided, errors are logged with console.error.Android runtime initialization
On Android, the Rive native library is automatically initialized at app startup. In rare cases (ABI mismatch, missing native libraries, etc.), this initialization can fail. UseRiveRuntime.getStatus() to check whether initialization succeeded:
On iOS, the runtime requires no explicit initialization —
getStatus() will always return { isInitialized: true }.