Shopify introduces React Native Skia, a 2D drawing library
React Native Skia is an open source project that brings the Skia drawing library to React Native. Skia is a cross-platform drawing library that powers Chrome, Android, Flutter, and others, and runs on iOS, Android, macOS, Windows, Linux, and the browser.
Goals
The post describes two aims for the project. The first is to give React Native, which the authors call "notorious for its limited graphical capabilities," a set of 2D drawing primitives that behave consistently across iOS, Android, and the Web. The second is to bridge the gap between graphic designers and React Native by offering UI capabilities comparable to a tool like Figma.
Built on JSI
To bring Skia to React Native, the project relies on the new React Native architecture's JavaScript Interface (JSI), which allows direct communication between JavaScript and native modules through C++ rather than asynchronous messages. This lets the Skia API be exposed directly to JavaScript.
The API is being made virtually 100% compatible with the Flutter API. According to the post, this lets the project draw on the completeness of Flutter's drawing API and eventually provide react-native-web support for Skia using CanvasKit, the Skia WebAssembly build that Flutter uses for its web apps.
Declarative API
Alongside the imperative API, React Native Skia provides a declarative API built on top of it. The project uses the React Reconciler to diff internal representation states and passes the differences to the Skia engine, which the post says enables composability for complex drawings and declarative optimizations.
Features
Available APIs include advanced image filters, shaders, SVG, path operations, vertices, and text layouts. A demo from William Candillon shows buttons with drop and inner shadows, a progress bar rendered with an angular gradient, and a bottom sheet using a backdrop filter to blur content behind it. Another example shows mesh gradients built with vertices.
Animations
Animations in React Native Skia work the same way as in Reanimated 2, with animation code written in JavaScript and run on a dedicated thread. For drawings that depend on an outside view, such as a React Native gesture handler, the project provides a direct connector to Reanimated 2.
Getting it
The team says it is working on new features to be shared in the upcoming months. The package can be installed with:
npm install @shopify/react-native-skia
The post credits Christian Falch, of the Fram X consultancy, and William Candillon, host of the "Can it be done in React Native?" YouTube series, who partnered to build the project.
Links
Source: shopify.engineering