Yes, and as you can see, things are not that trivial.
At the high level, you can approach it in two ways.
- WebView to localhost would be the first solution but is inherently not secure (or needs lot of work to make it so, and still)
- Another way is that the app container that bootstrap the webview have a scheme to serialize/deserialize JSON message between the JS environment and the app container (in rust in this case). And that is what Tauri nailed down.
In fact, Tauri also supports localhost, in prod and dev. And where it becomes insanely good is that for dev, you can use localhost and use something like servor to have hot reload when you can UI code, and when its time to pack your app for distribution, it bundles those html assets part of the binary.
Anyway, some Rust marvels are out there, and this is one of them.
(btw, this is for desktop applications, not browser extensions)