241
native bridge
also platform channel, React Native bridge
UI and native code exchange structured messages. They do not share objects.
What is native bridge?
A native bridge, or platform channel, sends JSON-like values between a UI runtime and Kotlin, Swift, or Objective-C. Calls are asynchronous. The UI thread must not block on them. Functions, class instances, and cyclic graphs do not cross. Errors need a code, not only a string.
Why does native bridge matter when vibe coding?
The draft passes a callback function or a giant object graph across the bridge, or it does file IO on the UI thread inside the native method. The screen freezes, or the call fails with a red box about a non-serializable value.
How do you do native bridge?
Define a small typed payload. Return results async. Do native work off the UI thread. Map errors to codes the UI handles.
How do you ask a model for native bridge?
Expose (action) as a platform channel. Arguments are (shape), JSON-serializable. Do the work off the UI thread. Return a result or an error code. Do not pass functions or class instances.
What goes wrong with native bridge?
A new channel for every call site, each with a slightly different shape. You cannot tell what the native side accepts.