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-native-middleware

v1.0.5

Published

Transport library between React Native and a website through a WebView

Readme

React Native Middleware

Setup

Required

  1. Node.js + npm - https://nodejs.org/fr/
  2. React Native project - https://reactnative.dev

Install the dependency

You should execute this command in your React Native project:

npm i react-native-middleware

How it works?

Design

The middleware makes it easy to pass data between the React Native App and Websites or encapsulated applications (such like JS bundle).

Transmission App/Middleware

Practical applications

Functionalities:

  • Network status: detect connection/disconnection with internet.
  • Storage: keep saved your data in the phone storage.
  • Notification: notify users of news.
  • Hardware access: it facilitates the implementation of sensors.

Usage

Test code is available: test/App.js

Step 1 - Import the library

Like any library

import { WebView } from './react-native-middleware';

Step 2 - Add the WebView

Define your WebView with its URL, its style ... see more

return (
    <View>
        <WebView source={'https://gitlab.com/Yarflam/react-native-middleware'} />
    </View>
);

Step 3 - Ping/Pong props

The WebView accepts two additional options:

  • receiveMsg: link your own function to data exchange (@args: topic:String, payload:any, sendMsg:Function)
  • scripts: run scripts when starting the WebView.

Try this:

export default function App() {
    /* Capture the messages (application side) */
    const receiveMsg = (topic, payload, sendMsg) => {
        if (topic === 'giveAnswer') {
            /* Replying */
            sendMsg('answer', payload === 'H2G2' ? 42 : 1337);
        }
    };
    /* Your WebView */
    return (
        <View>
            <WebView
                source={'https://gitlab.com/Yarflam/react-native-middleware'}
                receiveMsg={receiveMsg}
                scripts={[
                    function({ sendMsg, receiveMsg }) {
                        /* Receive a message (page side) */
                        receiveMsg('answer', answer => {
                            document.querySelector('body').innerHTML = answer;
                        });
                        /* Send a message (page side) */
                        sendMsg('giveAnswer', 'H2G2');
                    }
                ]}
            />
        </View>
    );
}

Step 4 - Page side

The middleware set a global variable in the page:

window.reactNativeMiddleware; // platform:Object, sendMsg:Function, receiveMsg:Function, request:Function

Or you can wait for the instance to initialize:

window.addEventListener('reactNativeMiddleware', e => {
    var reactNativeMiddleware = e.detail;
    // Do something - ex: call pending functions
});

reactNativeMiddleware.platform:0bject - Get information about the device

{
    "os": "android",
    "version": 30
}

reactNativeMiddleware.sendMsg:Function - Send a message to React Native application

reactNativeMiddleware.sendMsg('topic', payload);

reactNativeMiddleware.receiveMsg:Function - Receive an answer from React Native application

reactNativeMiddleware.receiveMsg('topic', payload => {
    // Do something
});

reactNativeMiddleware.request:Function - Send/Receive a request

reactNativeMiddleware.request('topic', payload, answer => {
    // Do something
});

Versions

  • v1.0.5: Support custom event at startup
  • v1.0.4: Fix README - npm/gitlab linking
  • v1.0.3: Write README + proper definition of the license
  • v1.0.2: Add .npmignore file
  • v1.0.1: Fix package.json (dev dependencies)
  • v1.0.0: First version

Author

  • Yarflam - initial worker

Licence

MIT License (MIT) - read more