2018-08-15 19:23:26 -07:00
# React Native WebView - a Modern, Cross-Platform WebView for React Native
2019-04-02 16:05:56 +02:00
2019-08-30 12:04:32 +02:00
[](https://github.com/react-native-community/react-native-webview)
[](http://makeapullrequest.com)
[](#contributors )
2019-06-22 00:24:19 +02:00
[](https://snyk.io/test/github/react-native-community/react-native-webview)
2020-01-07 10:34:15 +09:00
[](https://www.npmjs.com/package/react-native-webview)
[][lean-core-issue]
2018-08-12 21:52:47 -07:00
2018-09-08 10:42:02 -07:00
**React Native WebView** is a modern, well-supported, and cross-platform WebView for React Native. It is intended to be a replacement for the built-in WebView (which will be [removed from core ](https://github.com/react-native-community/discussions-and-proposals/pull/3 )).
2018-08-12 21:52:47 -07:00
2019-03-01 01:18:58 +01:00
## Core Maintainers - Sponsoring companies
2019-04-02 16:05:56 +02:00
2019-03-01 01:18:58 +01:00
_This project is maintained for free by these people using both their free time and their company work time._
2019-01-02 01:07:25 -08:00
2019-03-01 01:18:58 +01:00
- [Thibault Malbranche ](https://github.com/Titozzz ) ([Twitter @titozzz ](https://twitter.com/titozzz )) from [Brigad ](https://brigad.co/about )
- [Jamon Holmgren ](https://github.com/jamonholmgren ) ([Twitter @jamonholmgren ](https://twitter.com/jamonholmgren )) from [Infinite Red ](https://infinite.red/react-native )
2019-01-02 01:07:25 -08:00
2018-08-12 21:52:47 -07:00
## Platforms Supported
2019-08-30 12:04:32 +02:00
- [x] iOS
2018-10-13 01:03:00 +02:00
- [x] Android
2020-02-12 15:39:11 -08:00
- [x] macOS
2020-03-16 19:30:25 -07:00
- [x] Windows
2018-10-13 01:03:00 +02:00
2019-06-22 06:04:17 +08:00
_Note: Expo support for React Native WebView started with [Expo SDK v33.0.0](https://blog.expo.io/expo-sdk-v33-0-0-is-now-available-52d1c99dfe4c)._
2018-11-19 02:28:55 -08:00
2018-09-19 19:27:09 -07:00
## Getting Started
2018-08-12 21:52:47 -07:00
2019-03-01 13:23:37 +05:30
Read our [Getting Started Guide ](docs/Getting-Started.md ). If any step seems unclear, please create a detailed issue.
2018-08-12 21:52:47 -07:00
2019-03-01 01:18:58 +01:00
## Versioning
This project follows [semantic versioning ](https://semver.org/ ). We do not hesitate to release breaking changes but they will be in a major version.
**Breaking History:**
2019-04-15 00:53:50 -07:00
Current Version: 
2019-12-27 02:40:37 -08:00
- [8.0.0 ](https://github.com/react-native-community/react-native-webview/releases/tag/v8.0.0 ) - onNavigationStateChange now triggers with hash url changes
2019-08-30 12:18:44 +02:00
- [7.0.1 ](https://github.com/react-native-community/react-native-webview/releases/tag/v7.0.1 ) - Removed UIWebView
2019-08-30 12:04:32 +02:00
2019-05-20 00:36:51 +02:00
- [6.0.**2** ](https://github.com/react-native-community/react-native-webview/releases/tag/v6.0.2 ) - Update to AndroidX. Make sure to enable it in your project's `android/gradle.properties` . See [Getting Started Guide ](docs/Getting-Started.md ).
2019-05-20 10:23:52 +02:00
2019-03-01 01:18:58 +01:00
- [5.0.**1** ](https://github.com/react-native-community/react-native-webview/releases/tag/v5.0.0 ) - Refactored the old postMessage implementation for communication from webview to native.
2019-04-15 00:53:50 -07:00
- [4.0.0 ](https://github.com/react-native-community/react-native-webview/releases/tag/v4.0.0 ) - Added cache (enabled by default).
- [3.0.0 ](https://github.com/react-native-community/react-native-webview/releases/tag/v3.0.0 ) - WKWebview: Add shared process pool so cookies and localStorage are shared across webviews in iOS (enabled by default).
- [2.0.0 ](https://github.com/react-native-community/react-native-webview/releases/tag/v2.0.0 ) - First release this is a replica of the core webview component
2019-03-01 01:18:58 +01:00
**Upcoming:**
2019-09-02 23:30:46 +02:00
- this.webView.postMessage() removal (never documented and less flexible than injectJavascript) -> [how to migrate ](https://github.com/react-native-community/react-native-webview/issues/809 )
2019-03-01 01:18:58 +01:00
- Kotlin rewrite
- Maybe Swift rewrite
2018-09-19 19:27:09 -07:00
2018-08-12 21:52:47 -07:00
## Usage
2018-08-15 19:23:26 -07:00
Import the `WebView` component from `react-native-webview` and use it like so:
2018-08-12 21:52:47 -07:00
```jsx
2019-04-02 16:05:56 +02:00
import React , { Component } from 'react' ;
import { StyleSheet , Text , View } from 'react-native' ;
import { WebView } from 'react-native-webview' ;
2018-08-12 21:52:47 -07:00
// ...
class MyWebComponent extends Component {
2018-10-13 01:03:00 +02:00
render () {
2020-02-26 03:54:06 -03:00
return < WebView source = {{ uri : 'https://reactnative.dev/' }} />;
2018-08-12 21:52:47 -07:00
}
}
```
2018-11-19 02:32:22 -08:00
For more, read the [API Reference ](./docs/Reference.md ) and [Guide ](./docs/Guide.md ). If you're interested in contributing, check out the [Contributing Guide ](./docs/Contributing.md ).
2018-08-12 21:52:47 -07:00
2019-03-01 01:18:58 +01:00
## Common issues
2018-11-19 02:28:55 -08:00
2019-08-30 12:04:32 +02:00
- If you're getting `Invariant Violation: Native component for "RNCWebView does not exist"` it likely means you forgot to run `react-native link` or there was some error with the linking process
2018-11-19 02:28:55 -08:00
2019-02-05 15:15:02 +01:00
## Contributing
2018-09-08 10:42:02 -07:00
2019-02-05 15:15:02 +01:00
See [Contributing.md ](https://github.com/react-native-community/react-native-webview/blob/master/docs/Contributing.md )
2018-09-08 10:42:02 -07:00
2019-01-18 17:48:06 +01:00
## Contributors
2019-01-30 10:52:44 +02:00
Thanks goes to these wonderful people ([emoji key ](https://github.com/all-contributors/all-contributors#emoji-key- )):
2019-01-18 17:48:06 +01:00
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore -->
2019-05-17 09:28:05 +02:00
<table><tr><td align="center"><a href="https://twitter.com/titozzz"><img src="https://avatars1.githubusercontent.com/u/6181446?v=4" width="100px;" alt="Thibault Malbranche"/><br /><sub><b>Thibault Malbranche</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=titozzz" title="Code">💻</a> <a href="#ideas -titozzz" title="Ideas, Planning, & Feedback">🤔</a> <a href="#review -titozzz" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=titozzz" title="Documentation">📖</a> <a href="#maintenance -titozzz" title="Maintenance">🚧</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=titozzz" title="Tests">⚠️</a> <a href="#infra -titozzz" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#question -titozzz" title="Answering Questions">💬</a></td><td align="center"><a href="https://jamonholmgren.com"><img src="https://avatars3.githubusercontent.com/u/1479215?v=4" width="100px;" alt="Jamon Holmgren"/><br /><sub><b>Jamon Holmgren</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=jamonholmgren" title="Code">💻</a> <a href="#ideas -jamonholmgren" title="Ideas, Planning, & Feedback">🤔</a> <a href="#review -jamonholmgren" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=jamonholmgren" title="Documentation">📖</a> <a href="#maintenance -jamonholmgren" title="Maintenance">🚧</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=jamonholmgren" title="Tests">⚠️</a> <a href="#example -jamonholmgren" title="Examples">💡</a> <a href="#question -jamonholmgren" title="Answering Questions">💬</a></td><td align="center"><a href="https://github.com/andreipfeiffer"><img src="https://avatars1.githubusercontent.com/u/2570562?v=4" width="100px;" alt="Andrei Pfeiffer"/><br /><sub><b>Andrei Pfeiffer</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=andreipfeiffer" title="Code">💻</a> <a href="#review -andreipfeiffer" title="Reviewed Pull Requests">👀</a> <a href="#ideas -andreipfeiffer" title="Ideas, Planning, & Feedback">🤔</a></td><td align="center"><a href="https://twitter.com/mikediarmid"><img src="https://avatars0.githubusercontent.com/u/5347038?v=4" width="100px;" alt="Michael Diarmid"/><br /><sub><b>Michael Diarmid</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=Salakar" title="Code">💻</a> <a href="#review -Salakar" title="Reviewed Pull Requests">👀</a> <a href="#ideas -Salakar" title="Ideas, Planning, & Feedback">🤔</a> <a href="#tool -Salakar" title="Tools">🔧</a></td><td align="center"><a href="http://smathson.github.io"><img src="https://avatars3.githubusercontent.com/u/932981?v=4" width="100px;" alt="Scott Mathson"/><br /><sub><b>Scott Mathson</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=smathson" title="Code">💻</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=smathson" title="Documentation">📖</a></td><td align="center"><a href="https://github.com/YangXiaomei"><img src="https://avatars0.githubusercontent.com/u/8221990?v=4" width="100px;" alt="Margaret"/><br /><sub><b>Margaret</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=YangXiaomei" title="Code">💻</a> <a href="https://github.com/react-native-community/react-native-webview/commits?author=YangXiaomei" title="Documentation">📖</a></td><td align="center"><a href="https://stylisted.com"><img src="https://avatars2.githubusercontent.com/u/1173161?v=4" width="100px;" alt="Jordan Sexton"/><br /><sub><b>Jordan Sexton</b></sub></a><br /><a href="https://github.com/react-native-community/react-native-webview/commits?author=jordansexton" t
2019-03-21 15:31:14 +01:00
2019-01-18 17:48:06 +01:00
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors ](https://github.com/all-contributors/all-contributors ) specification. Contributions of any kind welcome!
2018-08-12 21:52:47 -07:00
## License
MIT
2019-11-12 05:48:24 -03:00
2020-05-28 20:55:00 -03:00
## Translations
2019-11-12 05:48:24 -03:00
This readme is available in:
- [Brazilian portuguese ](docs/README.portuguese.md )
2020-01-07 10:34:15 +09:00
[lean-core-issue]: https://github.com/facebook/react-native/issues/23313