react-native-view-shot: capturing a React Native view as a PNG, JPG or WebP
Snapshot a React Native view and save it to an image
At a glance
- What is it?
- react-native-view-shot rasterizes a mounted React Native view into a file, a base64 string or a data URI. It targets React Native 0.80+ and now covers the new architecture, with caveats on Android scroll views and web builds.
- Who is it for?
- Adopt react-native-view-shot if you are on React Native 0.80 or newer and need to turn a mounted view into a file, a base64 string or a data URI, especially if you need the same call to work on iOS, Android and react-native-web. Do not adopt it for video capture, for WebP or raw output on iOS, or for horizontal scroll views on Android, since the README states those are not expanded.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 1 day ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.
Star history
- gre/react-native-view-shot2,951 ★ · +2
| Repository | 2026-09-24 | 2026-11-22 |
|---|---|---|
| gre/react-native-view-shot | 2.9k | 3k |
2 Stars in the last 59 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
What react-native-view-shot captures, and what it refuses to
The library takes a mounted React Native view and rasterizes it. That is the whole contract. You hand it a ref or wrap content in the ViewShot component, and you get back an image URI, a base64 string or a data URI depending on the result option. The README describes the target as "Capture a React Native view to an image", and the package keywords list screenshot, viewshot, view-snapshot, snapshot and rasterize.
The audience is narrow on purpose. If you are building a share sheet that exports a card, a receipt preview, a chart thumbnail or a QR panel, this is the kind of tool you reach for. If you want to record a video, capture the whole screen including native modals, or screenshot something the user is not currently rendering, this is the wrong layer. The library captures React Native views, not the OS framebuffer, and it captures what is mounted.
The API surface is two entry points. The ViewShot component wraps children and exposes capture() through a ref, plus captureMode values of mount, continuous and update. The lower level captureRef(view, options) function does the same work imperatively. Everything else is options.
The mechanism: refs, draw calls, and a promise of a URI
captureRef returns a Promise. It resolves to the image URI, and it rejects when the snapshot fails. The README shows the shape directly: captureRef(viewRef, { format: "jpg", quality: 0.8 }) then resolves to a URI you log or store.
The options decide what comes back. format accepts png or jpg everywhere, plus webp and raw on Android. The default is png. quality is a 0.0 to 1.0 number and only applies to lossy formats such as jpg. width and height resize the output from the view bounds; omit them to keep the original pixel size. fileName is Android only and must be at least three characters. result picks the delivery method: tmpfile is the default and writes a temporary file that exists only while the app runs, base64 returns the raw string, and data-uri adds the Data URI scheme header. The README warns that base64 is not a data URI and that large images sent over the bridge can cause lag.
On the component side, captureMode controls when the work happens. Left undefined, nothing is automatic and you call capture() yourself. mount captures once when the component mounts, and the README notes image loading is not awaited, so if the view contains an Image you should omit captureMode and call capture() from Image#onLoad instead. continuous and update are marked EXPERIMENTAL and the README says continuous "will capture A LOT of images continuously". Treat both as tools for very specific cases rather than defaults.
On web, captures go through html2canvas-pro, which is an optional peer dependency loaded lazily on the first capture. That is a different rendering path from the native one, and the README is explicit that a missing html2canvas-pro fails at build time with Can't resolve 'html2canvas-pro' in webpack or Metro, or rejects at runtime with an install hint where modules resolve at runtime.
Installing react-native-view-shot and taking a first capture
The README gives three install paths. Autolinking covers the native side since React Native 0.60+, so on iOS you only need to run pod install afterwards.
npm install react-native-view-shot
npx pod-installIn an Expo project the README uses the Expo installer instead.
npx expo install react-native-view-shotIf you target web through react-native-web or Expo web, add the renderer yourself. It is optional, so native-only projects should not install it.
npm install html2canvas-proThe simplest first capture is the component with captureMode="mount" and an onCapture callback. The README shows this variant, where the URI arrives as the callback argument.
import { useCallback } from "react";
import { Text } from "react-native";
import ViewShot from "react-native-view-shot";
function ExampleCaptureOnMountSimpler() {
const onCapture = useCallback(uri => {
console.log("do something with ", uri);
}, []);
return (
<ViewShot onCapture={onCapture} captureMode="mount">
<Text>...Something to rasterize...</Text>
</ViewShot>
);
}Run that and the console prints a file URI for the rasterized view. If you would rather control the moment, skip captureMode and call capture() on a ref when you are ready, which is also the pattern the README recommends when the view contains an Image you need to wait for. A custom webpack or esbuild web build also has to define the __DEV__ global, because the library reads it as React Native code does; the README shows webpack.DefinePlugin and the esbuild --define flag for that.
Where react-native-view-shot breaks: scroll views, WebP and the bridge
The sharpest limitation is snapshotContentContainer. Set it to true and, when the captured ref is a ScrollView, the library captures the entire scrollable content instead of the visible viewport. The README says it works on both iOS and Android by temporarily expanding the ScrollView to its full content size during the draw and then restoring it. Then the caveats arrive. On Android only vertical ScrollView is supported; horizontal scroll views, backed by HorizontalScrollView, are not expanded and fall back to capturing the visible bounds. On iOS both axes work through UIScrollView. On Windows it is not supported at all, because UWP's RenderTargetBitmap respects the live ScrollViewer.
Format support is asymmetric too. webp and raw are Android only. The README also flags that webm is a deprecated alias for webp and produces WebP image data, not a video, which is the kind of naming trap that ends up in a bug report.
result: "base64" is the third trap. The string crosses the bridge, so the README tells you to use it only with small images because it may cause lag, and it is not a data URI. If you want something you can drop into an Image source, use data-uri instead.
Finally, captureMode: "mount" does not await image loading. A view containing a remote Image can capture before the image paints, and you get an empty frame with no error. The README's own workaround is to drop captureMode and call capture() from the Image onLoad handler. That is a real design cost, not a documentation gap.
react-native-view-shot against react-native-skia and native screenshot APIs
The closest alternative people search for is React Native Skia. The difference is architectural. Skia renders a canvas you draw into with its own drawing API, so the output is whatever you painted, independent of the mounted view tree. react-native-view-shot does the opposite: it captures a view that already exists in the layout, which means your capture looks exactly like what the user sees, and also means you cannot capture anything that is not mounted or that the platform will not draw into a bitmap. If your goal is a generated chart or a poster composed from scratch, Skia gives you control over every pixel. If your goal is "export this screen as it looks", view-shot is the shorter path.
Native screenshot APIs are the other comparison. Those read the OS framebuffer, so they can include native overlays and system UI. react-native-view-shot only sees React Native views, which is a boundary rather than a defect: it will not capture a native modal that sits outside the view tree, and it will not capture content that has scrolled out of a viewport unless snapshotContentContainer applies.
The web path is worth calling out as its own trade-off. Because captures go through html2canvas-pro, web output is produced by a DOM renderer, not the native draw call. The README notes react-native is an optional peer dependency so a web-only project can install react-native-web without pulling react-native, but that also means the web and native paths are two implementations behind one API. Expect divergence in edge cases rather than assuming parity.
Maintenance, licence and the upgrade bill
The repository is not archived, and the last push was on 2026-09-21. Releases v6.0.0 and v6.0.1 both landed on 2026-09-20, with v5.1.1 before them on 2026-06-20. That is a project with recent activity, and the README states new architecture support (Fabric plus TurboModules) from version 4.0+, with both old and new architectures supported.
The version requirements are the upgrade cost. The README lists React Native >= 0.80.0 and Node.js >= 20, and package.json sets the peer dependencies to react >= 18.0.0 and react-native >= 0.80.0, with html2canvas-pro ^2.0.0 as an optional peer. If you are on an older React Native line, this library is not an option until you move, and that move is the real cost, not the npm install. The repository still ships android/, ios/ and windows/ directories and podspec, so the native build participates in your app build and your pod install step.
Licence is MIT, which is permissive and imposes no copyleft obligation on your app. The README does not document rollback or a migration guide from v5 to v6, so if you are upgrading across that boundary, check the release notes rather than assuming the API is unchanged. Nothing here is legal advice; read the LICENSE file in the repository for the actual terms.
Editorial conclusion
Adopt react-native-view-shot if you are on React Native 0.80 or newer and need to turn a mounted view into a file, a base64 string or a data URI, especially if you need the same call to work on iOS, Android and react-native-web. Do not adopt it for video capture, for WebP or raw output on iOS, or for horizontal scroll views on Android, since the README states those are not expanded. Before wiring it into a release build, verify three things on your own device: that html2canvas-pro resolves if you ship web, that __DEV__ is defined if your bundler is not Metro or Expo, and that snapshotContentContainer behaves as you expect on the exact ScrollView you plan to capture.
Frequently asked questions
How do I install react-native-view-shot?
Run npm install react-native-view-shot and then npx pod-install for iOS, since autolinking handles the native side from React Native 0.60+. In Expo the README uses npx expo install react-native-view-shot instead.
What is react-native-view-shot?
It is a library that captures a mounted React Native view to an image, returning a file URI, a base64 string or a data URI. You use it either through the ViewShot component or the captureRef(view, options) function.
Does react-native-view-shot work with Expo?
Yes. The README gives npx expo install react-native-view-shot as the Expo install command, and notes that Expo web captures go through html2canvas-pro, which you must install separately.
Can react-native-view-shot capture a full ScrollView, not just the visible part?
Yes, with snapshotContentContainer set to true, which temporarily expands the ScrollView to its full content size during the draw and restores it afterwards. On Android only vertical ScrollView is supported, and Windows is not supported at all.
Which image formats does react-native-view-shot support?
png and jpg on all platforms, plus webp and raw on Android only. The default is png, and quality applies only to lossy formats such as jpg.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/gre-react-native-view-shot)Star history chart for your README
[](https://hysenlabs.com/projects/gre-react-native-view-shot)Was this useful?