wdym?
Now I can open up Tauri frontend inside the browser, like this:
And all functionality works the same as using it inside a normal app window.
You might be thinking:
Why is it something to do with the Designer?
Tauriis some kind of Devtool, no?
To help them design & iterate fast right inside the codebase, with coding agents.
Tauriis using Webview, so running it in any type of browser should work out-of-the-box, no?
Actually, that’s not the case. We had to build fastrepl/char/plugins/relay to enable it.
motivation
Like Ryo Lu said, the line between "developer" and "designer" is definitely getting blurry.
He even showed how he works, using something called Baby Cursor, within the "Cursor's integrated browser":
After watching this, I wanted to enable something similar to everyone who works in fastrepl/char.
And I first thought it would be simple. Tauri allows typical web frontend stacks to draw UI inside the Webview. So I could just open up localhost:1422 inside the Cursor, right?
Actually, it was not.
problem
Taurirelies on__TAURI_INTERNALS__globals that don't exist in a normal browser.- Things like
invoke(calling Rust commands) and event subscriptions break immediately outside the managed webview.
solution
fastrepl/char/plugins/relay does it. fastrepl/char#4007 is almost all it takes. (I pushed a bit more commits after this though)
How it works:
- A
shim.jsinjected by a Vite plugin replaces the missing__TAURI_INTERNALS__globals in the browser invoke()calls route over WebSocket to the Relay server, which runs the real Rust handler- Events (
emit/listen) are bridged the same way
flowchart LR Browser -->|invoke| Shim[shim.js] Shim -->|WebSocket| Relay[Relay] Relay --> Backend[Tauri] Backend -->|response| Browser
At this point, the problem is solved. But there is one more concern left.
tauri devcommand requiresRustand other dependencies.- most people are familiar with running some web app, but setting up
Rustand waiting build is not very approachable. It need lots of compute resource, storage, and time.
Then I realized that we have a Staging build that we don't distribute, but just exists for testing. Staging is built with devtools which enables custom devtools we built(like seeding data etc) and right click context menu in webview(like inspect menu).
Now anyone with the Staging build can just run it as Rust backend, and make code changes in TypeScript side for UI iteration.