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

@lolistream/react-native-resvg

v0.2.2

Published

resvg for React Native

Downloads

295

Readme

react-native-resvg

High-performance SVG to PNG renderer for React Native, powered by resvg via uniffi-bindgen-react-native. Rust implementation is based on svg2png-wasm, so most code based on svg2png-wasm might be easily converted

Installation

npm install @lolistream/react-native-resvg

Usage

import { Converter } from '@lolistream/react-native-resvg';

const converter = new Converter(
  undefined, // serifFamily
  undefined, // sansSerifFamily
  undefined, // cursiveFamily
  undefined, // fantasyFamily
  undefined, // monospaceFamily
);

// SVG string -> PNG ArrayBuffer
const pngData: ArrayBuffer = converter.convert(
  '<svg width="100" height="100">...</svg>',
  2,         // scale (optional)
  undefined, // width (optional)
  undefined, // height (optional)
  undefined, // background color (optional, e.g. "#fff")
);

Display in React Native

function arrayBufferToBase64(buffer: ArrayBuffer): string {
  const bytes = new Uint8Array(buffer);
  let binary = '';
  for (let i = 0; i < bytes.byteLength; i++) {
    binary += String.fromCharCode(bytes[i]!);
  }
  return btoa(binary);
}

const base64 = arrayBufferToBase64(pngData);
const uri = `data:image/png;base64,${base64}`;

<Image source={{ uri }} style={{ width: 200, height: 200 }} />

Custom Fonts

const converter = new Converter(
  'Georgia',    // serifFamily
  'Helvetica',  // sansSerifFamily
  undefined,
  undefined,
  'Courier',    // monospaceFamily
);

// Register a font from raw bytes (e.g. fetched or from assets)
converter.registerFont(fontArrayBuffer);

// List all registered font families
const fonts: string[] = converter.listFonts();

API

new Converter(serifFamily?, sansSerifFamily?, cursiveFamily?, fantasyFamily?, monospaceFamily?)

Creates a new SVG converter instance. All parameters are optional default font family overrides.

converter.convert(svg, scale?, width?, height?, background?)

Renders an SVG string to PNG.

| Parameter | Type | Description | |-----------|------|-------------| | svg | string | SVG markup | | scale | number \| undefined | Scale factor (default: 1.0) | | width | number \| undefined | Target width in pixels | | height | number \| undefined | Target height in pixels | | background | string \| undefined | Background color (CSS color string, e.g. "#ffffff") |

Returns: ArrayBuffer containing PNG data.

Throws: ResvgError on invalid SVG, invalid dimensions, or encoding failure.

Size behavior:

  • Both width and height set: renders at exact dimensions
  • Only width set: scales height proportionally
  • Only height set: scales width proportionally
  • Neither set: uses SVG intrinsic size multiplied by scale

converter.registerFont(font)

Registers a font for text rendering. font is an ArrayBuffer of the font file (TTF/OTF).

converter.listFonts()

Returns string[] of all registered font family names.

Building from source

Requires Rust toolchain and uniffi-bindgen-react-native.

# Android
npm run ubrn:android

# iOS
npm run ubrn:ios

For release builds (significantly faster rendering):

ubrn build {OS} --and-generate --release

License

MIT