Skip to main content

nitro-view-shot

nitro-view-shot captures NitroUI views as native images on iOS and Android. It is a Nitro module built with Nitro 1.0 (nitro-core 1.0.0-alpha.nightly.138), with a Swift implementation on iOS and a Kotlin implementation on Android.

import { ViewShotView, type ViewShotViewRef } from 'nitro-view-shot'

const shot = useRef<ViewShotViewRef>(null)
// <ViewShotView ref={shot}>…</ViewShotView>
const image = await shot.current?.capture() // nitro-ui-renderer Image

What it does​

CapabilityDetails
Capture a componentWrap content in ViewShotView and call capture() on its ref.
Capture any viewPass a mounted NitroUI ViewRef to ViewShot.capture.
Native resultResolves to a nitro-ui-renderer Image: encode it to PNG or JPEG, base64, or raw pixels.
Pixel densityRenders at the display's pixel density; width and height are in pixels.
Color8-bit sRGB with alpha on both platforms.
Subtree onlyViews drawn over the target are left out; parts an ancestor scrolls or clips out of sight are included.

Requirements​

RequirementVersion
nitro-ui-renderer0.3.0 or newer
react19.0.0 or newer
iOS16+ (NitroUI's minimum)
AndroidAPI 26+ (NitroUI's minimum)
nitro-core1.0.0-alpha.nightly.138.g43e09c161101, exactly; see Installation

Next steps​