react-native-bundle-loader
v0.1.0
Published
Allows to load remote bundle via http URL.
Downloads
353
Readme
react-native-bundle-loader
Allows to load remote bundle via URL. Useful for testing a Metro bundler running remotely.
Installation
yarn add react-native-bundle-loader
Usage
import BundleLoader, { BundlePrompt } from 'react-native-bundle-loader';
// ...
// You can use the component to provide the remote URL:
function SomeScreen() {
return <BundlePrompt />;
}
// Or call the `load` method explictly in your own prompt:
BundleLoader.load('https://some-remote-url/bundle.js');
Accessing a running react-native packager
With react-native-bundle-loader
you can also allow remote bundle accessing of a metro server running on a developer's machine.
Note: the app binary running on cellphone already has the react-native-bundle-loader lib installed and configured properly.
Exposing the metro server
- Ensure that a metro server is running on the developer machine (
yarn start
); - Expose the running metro server to the world. You can use any tool for generating a secure tunnel from a public endpoint to the locally running metro server like ngrok:
ngrok http 8081
- With
BundlePrompt
(or viaBundleLoader.load()
) pass the URL of the exposed metro server. Provide the params to the metro server:
dev
: based on the mode the binary was builttrue
for development orfalse
for releaseexcludeSource
:true
platform
:ios
orandroid
(currently only iOS is supported).
Example URL: https://example.ngrok.io/index.bundle?dev=false&platform=ios&excludeSource=true
Every accessing to the metro server will return the updated version of the code :slightly_smiling_face:
:warning: Disclaimer
Be careful about publishing binary versions with react-native-bundle-loader
supporting in the stores. A malicious code could be injected to your app and affect the users. We strictly recommend to distribute versions with custom bundle supporting enabled only internally.
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT