Capture views
as native images.
Wrap NitroUI content in a ViewShotView, call capture(), and get a native Image at the display's pixel density, drawn by Swift and Kotlin.
bun add nitro-view-shotTwo ways to capture
Wrap the content you own, or capture any NitroUI View you hold a ref to. Both resolve to the same Image.
Wrap and capture
A View whose ref captures what it renders.
Any mounted View
Pass a ViewRef you already hold.
Native on iOS
drawHierarchy at the display scale, in 8-bit sRGB.
Native on Android
Pixels copied off the JavaScript thread.
What a capture includes
The same behavior on iOS and Android, pinned by native tests that read pixel colors.
Pixel density
Renders at the display's scale; width and height are in pixels on both platforms.
Subtree only
Views drawn over the target are left out; parts scrolled out of sight are kept.
Clipping and shadows
The view's rounded clipping applies, and box shadows render natively.
Clear rejections
Empty or unmounted views reject with a fixed, documented message.
One call, one Image
The result is a nitro-ui-renderer Image: show it, encode it as PNG or JPEG, save it, or read its pixels.
Read the guidesconst shot = useRef<ViewShotViewRef>(null)
<ViewShotView ref={shot} style={{ background: 'white' }}>
<Text>Captured content</Text>
</ViewShotView>
const image = await shot.current?.capture()
const png = await image?.toEncodedImageDataAsync('png')
Capture your first view
Add the package, pin nitro-core, run nitro-ui prepare, and wrap a view.