RPC Anywhere

RPC Anywhere lets you create type-safe RPCs.

$ npm i rpc-anywhere

This is a demo of an RPC between this page ("parent") and a child iframe. Read the code: parent.ts and iframe.ts.

RPC Anywhere is transport agnostic, and is not limited to iframes. It works for Electron IPC, Web Workers, browser extension content scripts... Anything! Learn more.


parent

Waiting for the iframe to load...

The button is red.


iframe


about this demo

The blue container aboveto the left is an iframe (a different webpage loaded inside this one).

The iframe's page is separate from this one, and has a different JavaScript context. An RPC helps bridge the gap, allowing both pages to send messages and make requests to each other.


parent logs ·


iframe logs ·