RORK LABJP
MAX — Rork Max is built on Claude Code and Claude Opus 4.6, generating native Swift apps directly instead of React NativeAPPLE — Rork Max targets the whole Apple ecosystem: iPhone, iPad, Apple Watch, Apple TV, Vision Pro, and iMessageWORKFLOW — In practice, users settle into letting the AI scaffold while they rewrite the state management and data layer themselvesSEED — Rork raised a $15M seed led by Left Lane Capital in April, with Peak XV, True Ventures, and a16z Speedrun joiningPAPERLINE — Rork acquired app builder Paperline and says it will stay acquisitive to bring in engineering talentREVIEW — Three-month revisit reviews are growing, clarifying where the tool shines and where it doesn'tMAX — Rork Max is built on Claude Code and Claude Opus 4.6, generating native Swift apps directly instead of React NativeAPPLE — Rork Max targets the whole Apple ecosystem: iPhone, iPad, Apple Watch, Apple TV, Vision Pro, and iMessageWORKFLOW — In practice, users settle into letting the AI scaffold while they rewrite the state management and data layer themselvesSEED — Rork raised a $15M seed led by Left Lane Capital in April, with Peak XV, True Ventures, and a16z Speedrun joiningPAPERLINE — Rork acquired app builder Paperline and says it will stay acquisitive to bring in engineering talentREVIEW — Three-month revisit reviews are growing, clarifying where the tool shines and where it doesn't
Articles/Dev Tools
Dev Tools/2026-07-13Advanced

postMessage Is Fire-and-Forget — Designing a Correlated Request/Response Bridge Between a WebView and React Native

postMessage between a WebView and React Native is one-way, so you never learn whether the work you asked for actually succeeded. Here is a typed request/response bridge, with correlation IDs and timeouts, built in working TypeScript.

WebView2React Native203Rork503BridgeTypeScript8

Premium Article

I could not tell whether the save had really finished

I had built a small app in Rork, as an indie developer, and embedded an existing web-based markdown editor inside a WebView. When the native "Save" button was pressed, injectedJavaScript pulled the editor's content and sent it to my own backend. That part worked within an hour.

The trouble showed up when a user closed the screen right after tapping Save. The content had not been retrieved yet, but a "saved" toast still appeared. On slow devices, the opposite happened and the same content was submitted twice. Tracing it, I realized the cause was a single thing: window.ReactNativeWebView.postMessage is a one-way channel, and there is no built-in way to know whether the work you asked for actually succeeded.

This article shares the request/response bridge I built to close that gap — one that ties each send to its reply with a correlation ID, so on the native side you can simply write await bridge.call(...).

Why postMessage is fire-and-forget

WebView communication in React Native looks bidirectional, but it is really two independent one-way pipes. From native to web, you push a JavaScript string with injectedJavaScript or webviewRef.injectJavaScript(). From web to native, you call window.ReactNativeWebView.postMessage(string) and receive it in the native onMessage.

Those two pipes have nothing that links a request to its reply. When native injects "give me the content," the framework does not tell you which of the messages that later arrive at onMessage corresponds to that request. With a single message type this is fine. But once you add save, fetch, validate, and "where is the scroll position" as distinct operations, you can no longer tell which reply belongs to which request, and state gets tangled.

An HTTP request and its response line up because a TCP connection or an HTTP/2 stream ID binds them. postMessage has none of that. So give it one yourself — a correlation ID. That was the starting point of the design.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
A design that turns one-way postMessage into an awaitable call using correlation IDs
Cleaning up every request left dangling by a 5s timeout, unmounts, and reloads
Origin checks and a type allowlist so an embedded web page is never trusted blindly
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Dev Tools2026-04-28
Five Fix Patterns for TypeScript Errors That Refuse to Leave Your Rork-Generated Code
When Rork-generated React Native code is buried in red squiggles and the AI keeps re-introducing the same TypeScript errors, these five patterns and their concrete fixes are the first places to look.
Dev Tools2026-04-24
Rork WebView Is Blank or Won't Load: 6 Causes to Check Before You Ship
Dropped a WebView into your Rork app and got a silent blank screen on device? Here's the checklist I run through, in the order that catches the most bugs first.
Dev Tools2026-07-11
When Sentry Burned Through Its Event Quota in Days — Trimming Noise Before It Ships
A Sentry quota that empties early in the month is almost always a noise problem, not an error surge. Here is how to shrink event volume before it ships — with beforeSend, sampling, and grouping — while keeping the errors that actually matter inside the quota.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →