Skip to main content

Migrating from v4 to v5

v5 moves the library to Nitro Modules and to newer Readium toolkits. Most apps need build changes and a few small code changes.

Dependencies​

Add react-native-nitro-modules, which the library now depends on:

yarn add react-native-nitro-modules

iOS​

Update your Podfile: add Readium's spec repo as a source, and call the readium_pods and readium_post_install helpers. See Installation for the full snippet.

Android​

The Android implementation moves to a newer Readium Kotlin toolkit, which needs:

  • JDK 17.
  • Kotlin 2.3.20 or later.
  • compileSdkVersion 31 or later.

If the build then fails on missing java.time APIs, enable core library desugaring.

Code changes​

  • Navigation is imperative. Move the reader with ref.current.goTo(locator), alongside goForward() and goBackward(); see Navigation. The initial position is still set with file.initialLocation. On web, the useLocationObserver hook is gone.
  • Link is smaller. templated, height, width, bitrate, duration and alternates were removed, and rels is now a string[] instead of a Set<string>. type is only set by the web reader.
  • File is now ReadiumFile. File still works as a deprecated alias.