Read/Write Value API
Persist small strings on the device from JavaScript and read them back — for theme, language, session tokens, or onboarding state.
The Read/Write Value API persistently stores an arbitrary string on the device (via the app's private storage) and reads it back into your JavaScript. Values survive app restarts and cache clears — unless the OS wipes app data.
Writing a Value:
Everything after writevalue:// is stored verbatim as one string. Design your own format (query-string, JSON, CSV — whatever fits your web app):
<a href="writevalue://darkmode=on;user=42">Save</a>
Reading a Value:
When readvalue:// is triggered, the app injects the stored string back into the WebView so your JavaScript can read it:
<a href="readvalue://" onclick="setTimeout(showSettings, 200)">Load</a>
<script>
function showSettings() {
console.log(window.appSettings || "no settings yet");
}
</script>
Typical Use Cases:
- Remember a user's theme, language, or onboarding state offline.
- Cache a session token when you cannot rely on cookies.
- Persist a small local preference without a backend round-trip.
Notes: Values are per-app-install and per-device — they are not synced across devices. Keep values small; this API is intended for settings, not blob storage.