A UI that never stutters
Parse, resize and transform in a worker; keep the main thread for input and rendering.
hybrid-compute · local, worker, remote
Register a task once and let runTask() send it to the main thread, a Web Worker or a remote service over HTTP or WebSocket. Your code stays the same; only the strategy changes.
Use core with any mix of the three backends.
| Package | Runs on | What it does |
|---|---|---|
| @hybrid-compute/core | anywhere | The orchestrator. Picks a backend for each task by strategy; with auto it falls back from worker to local to remote. |
| @hybrid-compute/local | main | Runs registered tasks on the main thread. The right place for small, cheap work. |
| @hybrid-compute/worker | Web Worker | Runs tasks in a Web Worker, so heavy work never blocks rendering or input. |
| @hybrid-compute/remote | remote service | Sends tasks to a service over fetch or WebSocket, as JSON messages. |
Change the strategy, not the code.
// app.ts const compute = createHybridCompute({ local, worker, remote }); await compute.runTask('resizeImage', blob); // auto: worker, local, then remote await compute.runTask('resizeImage', blob, 'worker'); // always off the main thread await compute.runTask('summarise', text, 'remote'); // on your server
Parse, resize and transform in a worker; keep the main thread for input and rendering.
Run sensitive steps locally and send only what a remote service really needs.
Prefer local and worker backends, and reach for remote only when it is there.