How to use local HTML files for Webview in Expo?

I am trying to use the webview and I want to use a local HTML file however, from the documentation it says you need to place the android files in android/**, but with expo I don’t have those files? Is there a work around I can do?

1 Like

Looking also for help on this one. I’m using a weird workaround for now :

   const indexHtml = Asset.fromModule(require('./bibleWebView/dist/index.html'))
   await indexHtml.downloadAsync()
   this.HTMLFile = await FileSystem.readAsStringAsync(indexHtml.localUri)

   <WebView
            useWebKit
            onLoad={this.sendDataToWebView}
            onLoadEnd={this.injectFont}
            onMessage={this.receiveDataFromWebView}
            originWhitelist={['*']}
            ref={ref => {
              this.webview = ref
            }}

            source={{ html: this.HTMLFile }}
            injectedJavaScript={INJECTED_JAVASCRIPT}
            domStorageEnabled
            allowUniversalAccessFromFileURLs
            allowFileAccessFromFileURLs
            allowFileAccess
          />
4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.