npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-capture-view

v0.1.0

Published

Fabric-compatible React Native view, screen, and ScrollView capture for iOS and Android

Readme

react-native-capture-view

npm version CI

Capture a React Native view, screen, or ScrollView as an image on iOS and Android. Built for the New Architecture (Fabric + TurboModules).

Use this library when you need:

  • React Native screenshot capture for a specific view
  • full ScrollView content capture
  • full screen capture
  • a Fabric-compatible alternative to older view-shot libraries

Choose the API based on what you want to capture:

| API | Use when | |-----|----------| | CaptureView | Capture a specific rendered view subtree | | CaptureScrollView | Capture the full content of a plain ScrollView | | captureScreen() | Capture the currently visible screen |

Requirements

  • React Native >= 0.82
  • New Architecture enabled
  • iOS and Android
  • Works with Expo (dev builds / EAS builds, not Expo Go)

Installation

npm install react-native-capture-view

or

yarn add react-native-capture-view

iOS requires pod install:

cd ios && pod install

For Expo, use a dev build or EAS build (npx expo prebuild handles autolinking). Not compatible with Expo Go.

Usage

Capture a View

Wrap your content in CaptureView and capture it via ref:

import { useRef } from 'react';
import { CaptureView, type CaptureViewRef } from 'react-native-capture-view';

function Example() {
  const ref = useRef<CaptureViewRef>(null);

  const handleCapture = async () => {
    const result = await ref.current?.capture({ format: 'png' });
    console.log(result?.uri, result?.width, result?.height);
  };

  return (
    <CaptureView ref={ref} style={{ flex: 1 }}>
      {/* your content */}
    </CaptureView>
  );
}

Capture the Screen

import { captureScreen } from 'react-native-capture-view';

const result = await captureScreen({ format: 'jpg', quality: 0.8 });
console.log(result.uri);

Capture Full Scroll Content

Use CaptureScrollView to capture the entire scrollable content:

import { useRef } from 'react';
import { CaptureScrollView, type CaptureScrollViewRef } from 'react-native-capture-view';

function ScrollExample() {
  const ref = useRef<CaptureScrollViewRef>(null);

  const handleCapture = async () => {
    const result = await ref.current?.capture({ format: 'png' });
    // result.height will be the full content height
    console.log(result?.uri, result?.width, result?.height);
  };

  return (
    <CaptureScrollView ref={ref} captureStyle={{ height: 300 }}>
      {/* scrollable content */}
    </CaptureScrollView>
  );
}

CaptureScrollView is a thin JS wrapper that composes CaptureView with a real RN ScrollView. It accepts all ScrollViewProps (forwarded to the inner ScrollView) and adds capture() on its ref. Use captureStyle for the outer capture boundary and standard style/contentContainerStyle for scroll layout.

The ref only exposes capture(), not scroll imperative methods like scrollTo. If you need programmatic scroll control, use a separate ScrollView ref inside a CaptureView.

API

<CaptureView>

Captures its children as an image. For non-scrollable content.

| Prop | Type | Description | |------|------|-------------| | ref | CaptureViewRef | Ref to call capture() on | | style | ViewStyle | Standard view style | | children | ReactNode | Content to capture |

<CaptureScrollView>

A convenience wrapper that composes CaptureView + RN ScrollView. Captures the full scroll content.

| Prop | Type | Description | |------|------|-------------| | ref | CaptureScrollViewRef | Ref with capture() | | captureStyle | ViewStyle | Style for the outer capture boundary | | ScrollComponent | ComponentType | Custom scroll component (default: ScrollView). Must render all children — virtualized lists like FlatList will only capture mounted items. | | ...ScrollViewProps | | All standard ScrollView props forwarded to the inner scroll component |

ref.capture(options?)

Captures the view/scroll content. Returns Promise<CaptureResult>.

captureScreen(options?)

Captures the entire screen. Returns Promise<CaptureResult>.

CaptureOptions

| Option | Type | Default | Description | |--------|------|---------|-------------| | format | 'png' \| 'jpg' | 'png' | Image format | | quality | number | 1.0 | JPEG quality (0.0 - 1.0), only affects jpg | | output | 'tmpfile' \| 'base64' | 'tmpfile' | Output type |

CaptureResult

| Field | Type | Description | |-------|------|-------------| | uri | string? | File URI (when output: 'tmpfile') | | base64 | string? | Base64 string (when output: 'base64') | | width | number | Image width in points | | height | number | Image height in points | | format | 'png' \| 'jpg' | The format used |

Error Codes

| Code | Description | |------|-------------| | E_CAPTURE_FAILED | The native capture operation failed | | E_NO_WINDOW | Could not find the key window (iOS) | | E_NO_ACTIVITY | No current activity (Android) | | E_INVALID_SIZE | View has zero dimensions | | E_BITMAP_TOO_LARGE | Capture dimensions exceed the safe limit | | E_ENCODE_FAILED | Image encoding failed | | E_FILE_WRITE | Could not write temp file | | E_OOM | Out of memory (Android) | | E_NO_CONTENT | CaptureScrollView has no content |

Supported Scenarios

  • Standard views rendered by Fabric (Text, Image, View, etc.)
  • Full scroll content capture via CaptureScrollView
  • TextureView children on Android
  • PNG and JPG output
  • Temp file and base64 output

Known Limitations

  • SurfaceView content (camera, video, GL) -- renders as black on Android
  • WKWebView / WebView -- may produce blank output
  • System modals, alerts, or overlays outside the view hierarchy
  • Multi-window / multi-scene configurations
  • Maps (MapKit, Google Maps) -- compositor-based rendering
  • FlatList / SectionList full-content capture only captures mounted (visible) items, not the full list — use CaptureScrollView with plain ScrollView children for full-content capture
  • Web, Windows, macOS platforms

Notes

  • Temp files are written to the OS cache/tmp directory and may be cleaned up automatically by the system
  • Prefer tmpfile over base64 for large captures -- base64 encoding spikes memory
  • Use jpg with lower quality when file size matters
  • Very large scroll content captures may hit memory limits

License

MIT