# React Native for Web - Example App
This is a boilerplate React Native app with `react-native-web` installed and configured.
## Features
* index.html as an EJS template
* Code-splitting
* Saves time during development, saves bandwidth during updates
* Offline Plugin
* Caches all of your assets so your app works without an internet connection
Coming soon:
* Pre-rendering as static HTML
* [react-hot-loader](https://github.com/gaearon/react-hot-loader)
* Script to deploy your build to AWS S3, and optionally clear your CloudFlare cache
> Note: This boilerplate project only contains an example webpack configuration for React Native Web.
> You should merge this into your favorite React Native starter project.
## iOS and Android
Use the default React Native Packager for iOS and Android:
Script | Description
---|---
`react-native start` | Starts React Native Packager
`react-native run-ios` | Runs the iOS app
`react-native run-android` | Runs the Android app
## Web
`react-native-web` does not use the React Native Packager, so you need to use [webpack](https://webpack.github.io/) to compile your app. This example app contains a complete webpack configuration that is optimized for development and production.
Script | Description
---|---
`npm run web` | Starts the development server on port `3000`.
`npm run web:build:vendor-dev` | Builds the `react-native-web` library for development.
(The `web` task will automatically run this if it does not exist.)
`npm run web:build` | Builds your app for production.
(Runs `web:build:vendor` and `web:build:app`.)
`npm run web:build:vendor` | Builds the `react-native-web` library for production.
`npm run web:build:app` | Builds your app, and any implicit vendored libraries.
`npm run web:serve` | Serves the production build on port `3001`.
`npm run web:clean` | Deletes all generated files.
> Note: If you haven't changed any libraries in `vendor.webpack.config.js`, you can run `npm run web:build:app` to just compile your app's source code. `npm run web:build` will recompile everything.
## index.html
Your index file is generated from a template at [web/templates/index.ejs](/web/templates/index.ejs).
You can add variables to the [HTMLWebpackPlugin config](web/webpack.config.js#L49-L52) in `web/webpack.config.js`, and use these variables in the template.
### Examples:
In `web/webpack.config.js`:
```js
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'web/templates/index.ejs',
myVariable: 'foo',
}),
```
In `web/templates/index.ejs`:
```html