webview offline

Please provide the following:

  1. SDK Version: ~47.0.12
  2. Platforms(Android/iOS/web/all): all
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

As a beginner, I developed an app using WebView and completed the deployment. However, I found out that it cannot be used where there is no internet connection. After researching for solutions, I found three possible ways:

  1. Using Expo Asset API
  2. Using Expo FileSystem
  3. Caching
    GitHub - wonday/react-native-image-cache-wrapper: The best react native image cache wrapper.

The web page is a simple calculator and consists only of HTML, CSS, and JS files. There is no server.

I’m not sure which method is the most efficient. Can you please give me some advice? (Reference: https://forflight.netlify.app/)

I remember having a lot of issues with this. I don’t know what the best method would be. But what I did is the following.

In the app you were able to download specific HTML pages to your local file system.

let html = await FileSystem.readAsStringAsync(FileSystem.documentDirectory+‘thehtml.html’);

I then added it to a state:

In my webview:
source={{html: ${theHtml}}}

Don’t ask me why I did it like this. But this was the only way to get it to work for me on both android and iphone.

:pray: Thank you for the advice .
How about css js file then ??

I’ve added everything inline in one file because otherwise you would probably need some kind of local server on your phone

So technically saying it’s not a webview :slight_smile: !
Thank you !!