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-nitro-renderer

v0.0.1-alpha.17

Published

Install JavaScript dependencies from the repository root with `bun install`.

Readme

React Nitro Renderer

Install JavaScript dependencies from the repository root with bun install.

The JavaScript package exports React components such as View and Text, rendering functions, and registerApp. For a standard app, register the root component:

import { registerApp } from 'react-nitro-renderer'
import { App } from './App'

registerApp(App)

The renderer initializes runtime globals before loading its rendering dependencies. registerApp creates a native window and renders the component for each scene.

For custom window setup, use Application, ViewController, Window and WindowScene. Register the root callback with Application.registerRoot, then create the view controller and window:

import { Application, renderRoot, ViewController, Window } from "react-nitro-renderer";

Application.registerRoot((scene) => {
  const viewController = new ViewController();
  renderRoot(<App />, viewController);
  return new Window(scene, viewController);
});

React roots provide useSafeAreaInsets(), which subscribes to the closest view controller's root view and returns its insets in points:

function App() {
  const insets = useSafeAreaInsets();
  return (
    <View layout={{ flex: 1, paddingTop: insets.top, paddingBottom: insets.bottom }}>
      <Text>Inside the safe area</Text>
    </View>
  );
}

The hook is exported from react-nitro-renderer and throws outside a React Nitro root. Every native view exposes safeAreaInsets, including viewController.view. Insets are relative to that view's bounds, so a view entirely inside its parent's safe area reports zero. The controller's addOnSafeAreaInsetsChangedListener(listener) observes its root view. Call remove() on the returned subscription when it is no longer needed.

Light and dark mode

useColorScheme() returns 'light' or 'dark', following the system setting, and re-renders when it changes:

function Card() {
  const colorScheme = useColorScheme();
  return <View style={{ background: colorScheme === 'dark' ? 0x1c1c1eff : 0xffffffff }} />;
}

Outside components, Appearance.getColorScheme() returns the same value, and Appearance.addOnColorSchemeChangedListener(listener) observes changes. Call remove() on the returned subscription when it is no longer needed. On iOS, getColorScheme() throws when called before the app's first window is created, such as at the top level of a module.

Splash screens

The operating system displays the native launch screen before JavaScript starts. Window.showSplashScreen(resourceName) keeps the launch screen visible while React prepares its initial content. Call it before renderRoot, then call hideSplashScreen() from a layout effect once the content is ready:

import { useLayoutEffect } from 'react'
import { Application, renderRoot, ViewController, Window } from 'react-nitro-renderer'

function ReadyApp({ window }: { window: Window }) {
  useLayoutEffect(() => {
    window.hideSplashScreen()
  }, [window])
  return <App />
}

Application.registerRoot((scene) => {
  const controller = new ViewController()
  const window = new Window(scene, controller)
  window.showSplashScreen('launch_screen')
  renderRoot(<ReadyApp window={window} />, controller)
  return window
})

If startup waits for data, call hideSplashScreen() when the ready or error UI has committed instead. There is no timer or minimum duration.

On Android, NitroActivity uses AndroidX SplashScreen to retain the system starting window. After hideSplashScreen(), drawing stays blocked until the native root and queued List cell layouts are ready. JavaScript, layout and posted cell work continue while the starting window is visible. The first content frame then replaces it; there is no second splash overlay. Android controls its own exit transition. This applies only to initial startup, not runtime reload or later calls after the first content draw.

On iOS, UIKit lays out the currently committed view hierarchy before removing the storyboard overlay. It does not drain queued List updates. If initial rows must be visible, signal readiness from a mounted row rather than the parent's layout effect. Neither platform waits for future React commits, remote images, or other asynchronous content.

Configure each platform's native launch screen:

  • iOS: Bundle launch_screen.storyboard with an initial view controller. Set UILaunchStoryboardName to launch_screen in Info.plist and pass that name to showSplashScreen. Use static launch-screen views and bundled images. A missing storyboard throws; showing another resource replaces the overlay after loading succeeds. Window disposal removes it. Native window ownership preserves the same splash state through WindowScene.windows.
  • Android: Assign a launch theme inheriting Theme.SplashScreen to the Activity in AndroidManifest.xml. Set windowSplashScreenBackground, windowSplashScreenAnimatedIcon, and postSplashScreenTheme. Keep the icon inside the system's adaptive-icon safe area. NitroActivity installs the splash screen and switches to the regular theme, including on Android versions before 12. No layout resource or setTheme(...) override is needed. resourceName is ignored; the theme determines the artwork. A retained Window keeps its readiness state across Activity recreation, and the new Activity checks native layout again.

The example app includes both native configurations.

Shadows

Use View.style.boxShadow for a shadow cast by the rounded border box. It also works on a transparent container. The first entry in the list paints closest to the viewer. An inset shadow paints inside the padding edge.

<View
  layout={{ paddingHorizontal: 24, paddingVertical: 12 }}
  style={{
    background: 'white',
    cornerRadius: 24,
    boxShadow: [{ offsetX: 0, offsetY: 5, blurRadius: 16, color: '#0000001a' }],
  }}
>
  <Text color="black">Create account</Text>
</View>

Use Image.style.filter to cast a drop shadow from the painted image's alpha. Transparent areas in the artwork let the shadow follow the silhouette. Filters run in list order, so each drop shadow can also shadow the previous result.

<Image
  image={logo}
  layout={{ width: 76, height: 68 }}
  style={{ filter: [{ dropShadow: { offsetX: 0, offsetY: 0, standardDeviation: 8, color: '#ffffff80' } }] }}
/>

Offsets, blur and spread use logical units. Box shadows accept a nonnegative blurRadius, signed spreadDistance and inset. Drop shadows accept a nonnegative Gaussian standardDeviation. A box blur radius of 16 corresponds to a standard deviation of 8. Both operations require a color and both offsets. Other lengths default to zero. Remove the style or pass an empty list to clear it.

On Android, both styles use RenderEffect and require Android 12 (API 31) or later and hardware-accelerated drawing. Check Application.supportsShadows before applying them in an app that runs on older Android versions. Setting a nonempty shadow list on an unsupported version throws. On iOS, both styles use Core Animation. Shadows leave layout and hit targets unchanged.

View transforms

Scale and translation are flat style props:

<View style={{ scale: 1.2, scaleX: 1.5, translateX: 20 }} />

scale defaults to 1 and sets all three axes. scaleX, scaleY, and scaleZ override their respective axes. Scaling preserves translation and does not change layout dimensions. Native view refs expose setScale(x, y, z) and a readonly scale value with x, y, and z fields.

On iOS, exact zero scale values are applied as 0.00001 to avoid a UIKit/Core Animation bug that can make a view disappear immediately during an exit animation. This applies to all scale style props and setScale; the scale getter returns the applied values. Other finite scale values are preserved. Use opacity: 0 when the view must be fully transparent.

Public reports describe zero-scale transform interpolation failures and immediate disappearance when animating to zero.

Bundled images

Import an SVG, PNG, JPEG, or WebP from JavaScript and pass it directly to Image:

import { Image } from "react-nitro-renderer";
import icon from "./assets/icon.svg";

function Icon() {
  return <Image image={icon} resizeMode="contain" layout={{ width: 24, height: 24 }} />;
}

The generated module exports an ImageLoader for the existing image prop on ImageView. Imports with identical image contents and density variants share one loader. Only images retained in the bundle are packaged. SVGs keep their vector data; bitmap files keep their original encoding.

Place icon.png, [email protected], and [email protected] together to supply density variants. Import icon.png; the bundler collects the matching variants into one native image resource. A file without a suffix is 1x. An explicit @1x file is also supported, but cannot coexist with an unsuffixed file for the same image. If only higher-density files exist, import one of those files directly. On iOS, WebP variants are stored as data assets and decoded by UIKit at the selected display scale. Android uses its standard density-specific drawables.

Pass --asset-catalog <output.xcassets> to the bundler and add that generated catalog to the app target's resources. Run the bundling script before the Sources and Resources build phases and declare the catalog as its output. The example app includes this setup for both Debug and Release builds. Rebuild the app after changing images; Xcode validates and compiles them with the app's other image assets.

On Android, pass --android-assets-dir <directory>. The Gradle resource task copies bitmap variants into drawable-mdpi, drawable-xhdpi, and drawable-xxhdpi, and converts SVGs into native VectorDrawable XML. The generated resource directory is registered with Android's build system.

Colors

Color props such as style.background, style.borderColor, gradient colors, and Text's color accept a 0xRRGGBBAA number or a CSS color string: a named color ('tomato'), hex ('#ff6347', '#ff634780'), rgb(), rgba(), hsl(), or hsla(). An invalid color throws when the prop is set.

<View style={{ background: 'rgba(255, 99, 71, 0.5)', borderColor: '#25315a' }} />

Image decoding on Android

An Image view decodes a bundled PNG or JPEG for its measured pixel size and resize mode. For remote images, return the encoded bytes from an ImageLoader. Pass the loader to <Image image={photo} /> and reuse it for that URL.

const photo = new ImageLoader(async () => {
  const response = await fetch(url)
  if (!response.ok) throw new Error(`Image request failed: ${response.status}`)
  return response.arrayBuffer()
})

Set decodeSize="original" on a view that needs the source resolution, for example when magnifying a photo. To edit or export the pixels, call await photo.loadImage() directly. Both use the full resolution even if another view has displayed the same source as a thumbnail. A caller that supplies an already-decoded Image controls its resolution. Bundled SVGs remain vector-backed.

Text typography

Text accepts color, fontSize, fontWeight, font, lineHeight, numberOfLines, and ellipsizeMode:

<Text fontSize={22} lineHeight={30} color={0x25315aff} numberOfLines={2} ellipsizeMode="tail">
  A longer description that wraps onto a second line.
</Text>

Text defaults to a 17-point system font on iOS, 17sp on Android, regular weight, opaque black, and unlimited lines. numberOfLines={0} removes the line limit. ellipsizeMode="clip" clips text instead of adding a trailing ellipsis. lineHeight uses the same units as fontSize. Removing it restores the font's natural line spacing. Changes invalidate native text measurement and layout.

fontWeight accepts regular, medium, semibold, or bold for system fonts. Non-regular system weights require Android 9 or later.

Bundled fonts

Add a .ttf or .otf file to your app and import it where you render the text.

import { Text } from 'react-nitro-renderer'
import abel from './assets/fonts/Abel-Regular.ttf'

function Heading() {
  return <Text font={abel} fontSize={28}>A heading in Abel</Text>
}

The app build packages used font imports into the iOS asset catalog and Android font resources. Rebuild the app after changing the file. Each import selects an exact face with its own weight. Omit font to use the system font.

The example app's Typography screen lets you switch between Abel and the system font, compare clipping with tail truncation, and toggle a two-line limit.

List content padding

Use contentPadding to reserve space at the ends of a list without adding spacer rows. The padding scrolls with the items and reduces the space available to auto-sized items across the scroll axis. Edges are in points and default to zero. Include safe-area insets explicitly when the list extends into the safe area.

const insets = useSafeAreaInsets()

return (
  <List
    dataSource={source}
    renderers={renderers}
    contentPadding={{ bottom: insets.bottom + 16 }}
    layout={{ flex: 1 }}
  />
)

Text input

TextInput uses a native single-line field by default. Set multiline to use a wrapping editor that scrolls vertically within its bounds:

const [name, setName] = useState("");

<TextInput
  defaultValue=""
  onBeforeTextChange={(edit) => {
    return edit.proposedText.toUpperCase();
  }}
  onTextChanged={(change) => {
    setName(change.text);
  }}
  placeholder="Name"
/>;

<TextInput multiline defaultValue={"First line\nSecond line"} placeholder="Message" />;

onBeforeTextChange returns the accepted full text synchronously. Return edit.proposedText to accept an edit, edit.text to reject it, or another string to transform it. Omitting the callback accepts native edits. onTextChanged observes the actual result; calling setState there does not decide the edit.

<TextInput
  defaultValue="locked"
  onBeforeTextChange={(edit) => {
    return edit.text;
  }}
/>;

defaultValue sets the initial text; later changes are ignored. Use ref.setText(text) for programmatic changes. These calls bypass the decision callback and do not emit edit events. Keep decision callbacks synchronous and do not mutate the input inside them. A thrown error rejects the edit.

Provisional keyboard composition stays untouched. When composition is confirmed, the decision callback receives the text from before composition in edit.text and the completed text in edit.proposedText.

onTextChanged receives { text, selectedTextRange, markedTextRange }. Both ranges use UTF-16 offsets with an inclusive start and exclusive end. A zero-length selected range represents the caret; undefined means no selection. A marked range identifies provisional keyboard text awaiting confirmation, so JS can derive composition with change.markedTextRange !== undefined.

onSelectionChanged receives the same snapshot when the selection or marked range changes, including caret movement without a text edit. onTextChanged reports text or marked-range changes. Programmatic setText calls do not emit these native edit events. Replacements are deferred until composition ends; equal text updates preserve the native selection and composition.

Inputs default to 44 points high, or 120 for multiline. Override their dimensions with layout. Overflow defaults to hidden to keep text inside the input's viewport. Layout padding is applied to the text area. Unconstrained dimensions use the native input's fitting size. To hug the text in a row, omit width and allow shrinking to the row's available space:

<View layout={{ flexDirection: "row" }}>
  <TextInput defaultValue="Hello" layout={{ flexShrink: 1, padding: 10 }} />
</View>;

Native text and placeholder changes request a batched layout pass, including programmatic updates. Resizing does not require React state updates.

A ref exposes TextInputRef, with text, selectedTextRange, markedTextRange, isFocused, setText(text), focus() and blur(). Focus methods return whether the requested state was reached; focus requires an active window. addOnTextChangedListener and addOnSelectionChangedListener return subscriptions whose remove() method ends observation. setOnBeforeTextChange(callback) replaces the single edit decision callback; passing undefined removes it.

multiline selects the UIKit backing view at construction. Use a new React key to change it; this creates a new native input and resets its editing state.

ViewController.addOnSizeChangedListener(listener) observes native content-size changes in points. Read the initial dimensions with view.getFrame(); remove the returned subscription when finished. React roots and navigation screens use this listener to update their layout dimensions after resizing.

Native renderer

The Swift package exposes the ReactNitroRenderer library and depends on the local ../nitro-core and ../react-nitro-layout packages. The core package builds native sources copied from the pinned nitro-core dependency installed by bun install. Add Swift sources under Sources/ReactNitroRenderer/ and use import NitroModules to access Nitro's Swift types. C++ interoperability is enabled for Nitro's C++-backed types.

Package.swift owns the standalone host targets. Nitrogen generates their bindings from specs configured with "environment": "bare":

  • ReactNitroRendererCxx: nitrogen/generated/shared/c++.
  • ReactNitroRendererAppleCxx: the generated C++ bridge declarations.
  • ReactNitroRenderer: handwritten Swift and nitrogen/generated/apple/swift.
  • ReactNitroRendererSwiftBridge: nitrogen/generated/apple/c++, the generated bridge implementation, and the public autolinking API.

The ReactNitroRenderer product includes both the Swift module and its C++ wrappers. Generated Swift imports ReactNitroRendererAppleCxx explicitly. Regenerate bindings with bun run specs after changing specs or updating Nitrogen.

Register the generated HybridObject classes before using their JavaScript classes:

#include <ReactNitroRenderer/ReactNitroRendererAutolinking.hpp>

margelo::nitro::renderer::registerHybridClasses();

Build the Swift package from this directory:

swift build

Use Swift 6.4's default Swift Build backend (or Xcode). The C++ wrappers use its GENERATED_MODULEMAP_DIR to include Swift's generated header after the C++ types it references; importing that header as an isolated Clang module loses those types.

Generate native bindings from the TypeScript specs with bun run specs.

Android renderer

Android uses native view groups, TextView, ScrollView, and Fragment-backed view controllers. Kotlin owns the views; operations cross JNI individually. Native animation runs without per-frame JavaScript callbacks. The layout engine uses the display density to round point dimensions to physical pixels.

Android currently supports one application window per Activity. Uniform scale applies to X/Y; independent Z scale is rejected. Both corner-curve preferences use circular corners. Native springs treat duration as a settling-time hint.

Android TextInput uses native EditText for single-line and multiline editing. Text, UTF-16 selection, keyboard composition, focus, and synchronous edit decisions use the existing JS API. A custom Editable applies whole-text transformations; composition is evaluated only after confirmation. Native measurement includes text and placeholders and invalidates layout when they change.

Android images use Bitmap for pixel data and native drawables for resources. Vector resources stay vector-backed in ImageView; exporting pixels or transforming them materializes a bitmap. Async decoding, encoding, transforms, and file access run on worker threads. Raw channel conversion runs in one C++ operation.

JPEG and PNG encoding are supported. HEIC encoding and SF Symbols throw explicit unsupported-operation errors on Android. Android rotations materialize their pixels, and raw pixel export returns CPU-backed RGBA or RGBX data.

Imported images are packaged through the bundler's --android-assets-dir output. PNG, JPEG, and WebP variants become native bitmap resources. SVGs use the Android SDK's VectorDrawable converter; features it cannot represent fail the Android build. No runtime SVG parser is needed.