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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-electron

v0.19.0

Published

Electron extensions to React Native for Web

Downloads

4,705

Readme

React Native Electron

Electron extensions to React Native for Web

Introduction

This project aims to provide extensions to React Native for Web targeted to the Electron environment to support additional modules exposed by React Native (Alert) or alternative implementations (Linking) using Electron APIs.

Installation

npm install react-native-electron

electron, react and react-native-web are required peer dependencies, make sure to install them as well:

npm install electron react react-native-web

react-art is also needed if you use ART.

Electron setup

In order for the APIs exposed by react-native-electron to be accessible in Electron's render process, the following setup must be applied:

  • The react-native-electron/main module must be imported in the main process
  • BrowserWindow instances must be created with the preload script from react-native-electron/preload, for example:
webPreferences: {
  preload: require('path').resolve(
    require.resolve('react-native-electron/preload'),
  ),
},

Example

See the example directory for the source code and Webpack config.

To run the demo app, fork this repository and run the following commands in the root folder:

  • yarn install
  • yarn build

Then in the example folder:

  • yarn install
  • yarn start

Usage with Expo application

This module can be used with Expo application (created by expo-cli) using the following steps:

  • Follow this guide's setup
  • Run yarn expo-electron customize in order to eject expo-electron's webpack configuration
  • Edit ./electron/webpack.config.js as follows:
const { withExpoWebpack } = require('@expo/electron-adapter')

module.exports = (config) => {
  const expoConfig = withExpoWebpack(config)
  expoConfig.resolve.alias['react-native$'] = 'react-native-electron'
  return expoConfig
}

Note this is a partial solution, as Expo's default webpack configuration includes more aliases to react-native, but it should cover all of react-native-electron's APIs.

APIs

Alert

React Native's Alert implementation using Electron's dialog

Alert.alert(
  title: string,
  message: ?string,
  buttons: ?Array<{text: string, onPress?: () => void}> = [],
  type: ?('none' | 'info' | 'error' | 'question' | 'warning') = 'none'
): void

Linking

React Native's Linking implementation using Electron's app and shell APIs.

Linking.openURL(url: string): Promise<void>

Linking.addEventListener(type: string, handler: Function): void

Linking.removeEventListener(type: string, handler: Function): void

Linking.canOpenURL(): Promise<true>: always resolves to true

Linking.getInitialURL(): Promise<?string>: resolves with the process.argv[1] value, expecting the app to be opened by a command such as myapp myapp://test

Platform

React Native's Platform

Platform.isElectron: boolean

Platform.OS: string

Platform.nativeOS: string

Platform.select(
  win32?: any,
  linux?: any,
  darwin?: any,
  electron?: any,
  web?: any,
  default?: any
): any

License

MIT
See LICENSE file.