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

rn-web-preview

v0.1.0

Published

React Native web preview library with advanced features

Downloads

25

Readme

rn-web-preview

A React Native native module for web preview with advanced features for Android and iOS.

Features

  • 🌐 URL preview with HTML content
  • 📱 Cross-platform support for Android and iOS
  • 🔗 Auto-linking support (React Native ≥ 0.60)
  • 🎯 TypeScript type definitions included
  • Promise-based API
  • 📊 Screenshot capture (base64)
  • 🎨 Customizable dimensions
  • 🔧 JavaScript control
  • 📦 Zero dependencies (peer dependencies only)

Installation

npm install rn-web-preview
# or
yarn add rn-web-preview

For React Native ≥ 0.60, the library will auto-link. After installation, rebuild your app:

# iOS
cd ios && pod install && cd ..
npx react-native run-ios

# Android
npx react-native run-android

Platform Setup

iOS Setup

Add the following permission to your ios/YourApp/Info.plist:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

Android Setup

The library automatically adds required permissions (INTERNET, ACCESS_NETWORK_STATE).

Usage

Basic Example

import WebPreview from 'rn-web-preview';

// Preview URL
const result = await WebPreview.previewURL('https://example.com');
console.log(result.title);
console.log(result.text);

Preview HTML

// Preview HTML content
const html = '<html><body><h1>Hello World</h1></body></html>';
const result = await WebPreview.previewHTML(html);
console.log(result.html);

Advanced Options

const result = await WebPreview.previewURL('https://example.com', {
  width: 1080,
  height: 1920,
  enableJavaScript: true,
  enableCache: true,
  timeout: 30000,
  waitForSelector: '.content',
  waitForNavigation: true,
});

API Reference

Methods

previewURL(url: string, options?: WebPreviewOptions): Promise<WebPreviewResult>

Previews a URL and returns the content.

interface WebPreviewOptions {
  url?: string;
  width?: number;
  height?: number;
  enableJavaScript?: boolean;
  enableCache?: boolean;
  userAgent?: string;
  headers?: Record<string, string>;
  timeout?: number;
  waitForSelector?: string;
  waitForNavigation?: boolean;
}

interface WebPreviewResult {
  html?: string;
  text?: string;
  title?: string;
  screenshot?: string; // base64
  width?: number;
  height?: number;
  url?: string;
  loadTime?: number;
}

previewHTML(html: string, options?: WebPreviewOptions): Promise<WebPreviewResult>

Previews HTML content and returns the rendered result.

clearCache(): Promise<void>

Clears the web preview cache.

clearCookies(): Promise<void>

Clears all cookies.

getUserAgent(): Promise<string>

Gets the current user agent string.

setUserAgent(userAgent: string): Promise<void>

Sets a custom user agent string.

Events

  • onLoad: Preview loaded successfully
  • onError: Error occurred during preview
  • onProgress: Loading progress (0-100)
interface WebPreviewError {
  code: string;
  message: string;
}

Error Codes

INVALID_URL, NETWORK_ERROR, TIMEOUT, NOT_AVAILABLE, UNKNOWN

Platform Differences

Android: Uses WebView for rendering, supports custom user agents and headers

iOS: Uses WKWebView for rendering, requires iOS 12.0+, supports advanced features like JavaScript control

Requirements

  • React Native ≥ 0.64.0
  • Android: minSdkVersion 21
  • iOS: iOS 12.0+

License

MIT

Author

afzaal