<WebView source={{ html: "<h1>Hello</h1>" }} />

Documentation available here: http://facebook.github.io/react-native/docs/webview.html#content

Answer from John Shammas on Stack Overflow
🌐
GitHub
github.com › react-native-webview › react-native-webview › blob › master › docs › Guide.md
react-native-webview/docs/Guide.md at master · react-native-webview/react-native-webview
Note that setting an html source requires the originWhiteList property to be set to ['*']. import React, { Component } from 'react'; import { WebView } from 'react-native-webview'; class MyInlineWeb extends Component { render() { return ( <WebView originWhitelist={['*']} source={{ html: '<h1>This is a static HTML source!</h1>' }} /> ); } }
Author   react-native-webview
🌐
React Native Archive
archive.reactnative.dev › docs › webview
🚧 WebView · React Native Archive
import React, { Component } from 'react'; import { WebView } from 'react-native'; class MyInlineWeb extends Component { render() { return ( <WebView originWhitelist={['*']} source={{ html: '<h1>Hello world</h1>' }} /> ); } }
Discussions

How to Load local HTML and local js in react-native-webview in IOS?
For me, this was easy to do with the core RN webview, but it failed once I switched to the react-native-webview community package. This is how I fixed it . I'm using this in a production app now and it's working fine (although I should note I inline all the JS in the html file I'm importing - you may want to do the same. I use HtmlWebpackInlineSourcePlugin in webpack to do that). More on reddit.com
🌐 r/reactnative
15
3
September 3, 2019
Load local html file
Hi, I try to load my html page: But it does not render the content as html, but as t... More on github.com
🌐 github.com
9
March 6, 2019
🌐
Expo Documentation
docs.expo.dev › third-party libraries › react-native-webview
react-native-webview - Expo Documentation
import { WebView } from 'react-native-webview'; import Constants from 'expo-constants'; import { StyleSheet } from 'react-native'; export default function App() { return ( <WebView style={styles.container} originWhitelist={['*']} source={{ html: '<h1><center>Hello world</center></h1>' }} /> ); } const styles = StyleSheet.create({ container: { flex: 1, marginTop: Constants.statusBarHeight, }, });
🌐
DZone
dzone.com › coding › javascript › react native webview — loading html in react native
React Native WebView — Loading HTML in React Native
June 17, 2020 - Since the in-built web-view feature of React Native is to be deprecated, we learned how to make use of the third party web view plugin named react-native-webview. First, we learned how to render the simple HTML content using the WebView component. Then, we got a detailed explanation of how to use the WebView component and its props to render the entire HTML content from the URL along with the loading indicator.
🌐
npm
npmjs.com › package › react-native-html-webview
react-native-html-webview - npm
December 9, 2015 - Uses an HTML Sanitizer to remove only let through a whitelist of tags and attributes (so it removes all javascript). Also supports automatically adjusting the height of the webview to contain the contents you give it.
      » npm install react-native-html-webview
    
Published   Dec 09, 2015
Version   0.0.17
Author   Thomas Parslow
🌐
About React
aboutreact.com › home › load local html file or url in react native using react-native-webview
Load Local HTML File or URL in React Native using react-native-webview
December 3, 2022 - In this example, we will use the WebView component from react-native-webview. We will make a single page where we will have 3 buttons which will load the data in WebView from different resources. Different tasks that you can see in this example are: <WebView style={{flex: 1}} originWhitelist={['*']} source={{ uri: "https://aboutreact.com" }} style={{ marginTop: 20 }} javaScriptEnabled={true} domStorageEnabled={true} /> <WebView style={{flex: 1}} originWhitelist={['*']} source={{ html: '<h1>Hello</h1>' }} style={{ marginTop: 20 }} javaScriptEnabled={true} domStorageEnabled={true} />
🌐
Instamobile
instamobile.io › react-native-tutorials › react-native-webview
React Native WebView Implementation | React Native App Templates & Themes
March 13, 2022 - In this tutorial, we learned about the web view property of React Native. Since the in-built web-view feature of React Native is to be deprecated, we learned how to make use of the third-party web view plugin named react-native-webview. First, we learned how to render simple HTML content using the WebView component.
Find elsewhere
🌐
LogRocket
blog.logrocket.com › home › how to render html to react native
How to render HTML to React Native - LogRocket Blog
June 4, 2024 - Apart from the react-native-render-html library, there’s one more option for rendering web components into React Native applications — React Native WebView.
🌐
LogRocket
blog.logrocket.com › home › react native webview: a complete guide
React Native WebView: A complete guide - LogRocket Blog
August 12, 2024 - To use React Native WebView to embed a web component, you either provide a URL for the web content or embed an inline HTML.
🌐
Medium
medium.com › yonder-techblog › react-native-offline-content-display-with-local-html-files-in-webview-7d22a0cf46fb
React Native: Offline Content Display with Local HTML Files in WebView | by Alex-Stefan Albu | Yonder TechBlog | Medium
February 21, 2024 - To display HTML files in a React Native app using a WebView component, you first need to import the WebView from the ‘react-native-webview’ library. Then, you can use the WebView component in your JSX/TSX code and specify the source of the HTML file using the ‘source’ prop.
🌐
GitHub
github.com › react-native-webview › react-native-webview › blob › master › docs › Reference.md
react-native-webview/docs/Reference.md at master · react-native-webview/react-native-webview
This document lays out the current public properties and methods for the React Native WebView. ... Loads static HTML or a URI (with optional headers) in the WebView.
Author   react-native-webview
🌐
Medium
medium.com › @krissanawat101 › how-to-use-react-native-webview-9dfd0e3c90fc
How to use React Native WebView?. In React Native, WebViews enable access… | by Kriss | Medium
December 14, 2021 - Since the in-built web-view feature of React Native is to be deprecated, we learned how to make use of the third-party web view plugin named react-native-webview. First, we learned how to render the simple HTML content using the WebView component. Then, we got a detailed explanation of how to use the WebView component and its props to render the entire HTML content from the URL along with the loading indicator.
🌐
npm
npmjs.com › package › react-native-htmlview
react-native-htmlview - npm
November 2, 2023 - A component which renders HTML content as native views. Latest version: 0.17.0, last published: 3 years ago. Start using react-native-htmlview in your project by running `npm i react-native-htmlview`. There are 56 other projects in the npm registry ...
      » npm install react-native-htmlview
    
Published   Nov 02, 2023
Version   0.17.0
🌐
KindaCode
kindacode.com › article › how-to-render-html-content-in-react-native
How to render HTML content in React Native - KindaCode
You can use it to render inline HTML for both Android and iOS as well. ... import { WebView } from 'react-native-webview'; /* ......
🌐
DEV Community
dev.to › thebuildguy › how-to-use-webview-in-react-native-3gma
How to use WebView in React Native? - DEV Community
August 22, 2024 - Rest apart, whatever you pass inside postMessage can be accessed in React Native through the callback passed into onMessage prop. onMessage is a prop for the Webview which takes a callback and is triggered anytime a message is sent using postMessage. ... import React from "react"; import { View } from "react-native"; import { WebView } from "react-native-webview"; const getRandomColor = () => { let letters = "0123456789ABCDEF"; let color = "#"; for (let i = 0; i < 6; i++) { color += letters[Math.floor(Math.random() * 16)]; } return color; }; class App extends React.Component { render() { const
🌐
GitHub
github.com › jsdf › react-native-htmlview
GitHub - jsdf/react-native-htmlview: A React Native component which renders HTML content as native views · GitHub
import React from 'react'; import {StyleSheet} from 'react-native'; import HTMLView from 'react-native-htmlview'; class App extends React.Component { render() { const htmlContent = `<p><a href="http://jsdf.co">&hearts; nice job!</a></p>`; return ( <HTMLView value={htmlContent} stylesheet={styles} /> ); } } const styles = StyleSheet.create({ a: { fontWeight: '300', color: '#FF3366', // make links coloured pink }, });
Starred by 2.8K users
Forked by 454 users
Languages   JavaScript 97.4% | Shell 2.6%
🌐
Reddit
reddit.com › r/reactnative › how to load local html and local js in react-native-webview in ios?
r/reactnative on Reddit: How to Load local HTML and local js in react-native-webview in IOS?
September 3, 2019 -

I am trying to load a charting library in webview. I have tried many answers on StackOverflow and GitHub but I was only able to display it correctly on Android using {uri: 'file:///android_asset/www/index.html'} but on iOS when I do import HTML_FILE from "./resources/index.html"; ORconst HTML = require('./resources/index.html'); it doesn't work.

The app shows a blank screen, and the metro bundler throws resources/highcharts/highcharts.js' cannot be loaded as its extension is not registered in assetExts.

PS:I followed similar approach for iOS : https://aboutreact.com/load-local-html-file-url-using-react-native-webview/

I have added simmilar question on StackOverflow as well : https://stackoverflow.com/questions/57726507/add-local-html-and-js-file-using-react-native-webview

PPS :"react-native": "0.60.5","react-native-webview": "^7.0.1"
I do not use EXPO

🌐
GitHub
github.com › react-native-webview › react-native-webview › issues › 392
Load local html file · Issue #392 · react-native-webview/react-native-webview
March 6, 2019 - <html> <head> <title>Page Title</title> </head> <body> <h1>My First Heading</h1> <p>My first paragraph.</p> </body> </html>
Author   react-native-webview