@hozo/webview
v0.4.0
Published
Universal embedded web content for Hozo: an iframe on the Web and react-native-webview on Native.
Maintainers
Readme
@hozo/webview
Web content inside a Hozo application (#160): an <iframe> on the Web, and react-native-webview on React Native.
import { WebView } from '@hozo/webview'
<WebView
src="https://example.com/checkout"
title="Payment form"
onMessage={({ data }) => setPaid(data?.paid === true)}
className="h-96 w-full"
/>- Named.
titleis required. WCAG 4.1.2 asks every frame for a name, and a reader that lands on an unnamed frame says "frame" before the person has decided whether to go in. On Native it is the view'saccessibilityLabel. - Its own messages only. On the Web,
onMessagereceives a message only when itssourceis this iframe's window, so another frame or another tab cannot speak through it. Which origin to trust inside the frame is the application's call, onmessage.origin. On Native, a page posts withwindow.ReactNativeWebView.postMessage(JSON.stringify(…)), and the data arrives parsed, so one handler reads both. - Lazy on the Web (
loading="lazy").sandbox,allowandreferrerPolicypass through to the iframe. - No native code of its own. On React Native it uses
react-native-webviewwhen the application has installed it, which is the resolved-provider seam of #353. Without it, the address is shown as a link that opens the browser, named bytitle, rather than as an empty box. A warning says what to install.
Not part of @hozo/core. A web view is a dependency an application chooses, and an application that embeds nothing should carry none of it.
Part of Hozo, a universal UI framework for React Native, compiled by Rust, with native semantics on every platform, first-class accessibility, and diagnostics for humans and AI agents alike. Most applications install @hozo/core and one build integration; see Getting started. Source and issues: github.com/iray-tno/hozo.
