Skip to main content

Error handling

This page only applies to the new runtime - not the legacy runtime.

Hook errors

The loading hooks return an error instead of throwing. Check it alongside the loading state:
  • useRiveFile sets error when the file can’t be loaded or decoded.
  • useViewModelInstance sets error when the requested view model, artboard, or instance doesn’t exist. With required: true, it throws instead, so you can handle it with an error boundary.
  • The property hooks (useRiveNumber, useRiveTrigger, and so on) set error when 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 the onError callback prop to handle errors during view configuration or runtime operations:

Error types

The following error types may occur during view operations:
In 0.5.0 and later, view errors are always reported as RiveErrorType.Unknown. Use error.message for details. The specific error types are only reported in 0.4.x.
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. Use RiveRuntime.getStatus() to check whether initialization succeeded:
On iOS, the runtime requires no explicit initialization — getStatus() will always return { isInitialized: true }.
Advanced: If you need full control over when initialization happens, you can disable automatic initialization by adding Rive_RiveRuntimeAndroidSkipSetup=true to android/gradle.properties and calling RiveRuntime.initialize() yourself. This is not recommended for most apps — only use this if you have a specific reason to defer initialization.