kolistivra
kolistivra

Reputation: 4429

The relationship between local web server and the Metro Bundler in React Native

I have read through some similar answers, and through Metro's and React Native's documentation, but I am still not clear. How exactly are the local web server (run through react-native start) and Metro bundler related to each other? Although there's information about Metro itself, not much is available regarding the web server.

Upvotes: 0

Views: 600

Answers (1)

no_fate
no_fate

Reputation: 1705

They are not related as tools.

Local Web server is a just node.js server on your local machine.

Metro bundler is a tool for js code that can make js bundles for react native projects, for example, there is webpack - another tool for the bundling js for web. Also you can see comparison of bundlers in google.

The main thing that the apk or ipa have to have js bundle inside.

For example this will make bundle for ios native project without running server:

react-native bundle --entry-file src/index.js --platform ios --dev false
--bundle-output ios/main.jsbundle --assets-dest ./ios --sourcemap-output
ios/main.bundle.map

After that just run project.

But

If you want to use hot reload and other features of RN, you need call

react-native run-ios

that will run local server and bundler inside this server for rebundling js after saving new code or tapping reload at developer menu

Upvotes: 1

Related Questions