Share your data.
Not copies.
zerocopy is a JavaScript and TypeScript library for shared, immutable collections. One dataset. Your UI and workers, reading together without cloning their backing storage.
Direct reads. Familiar collections. Tasks optional.
Move the work.
Not the whole dataset.
Search a stream. Inspect a record. Read locally on either thread.
Connect a worker once. A session delivers snapshots. After attachment, .get() is a synchronous local read. It does not ask the main thread for a value.
Tasks only schedule work.
// With your existing state and worker
await state.connect(worker);
// Read directly on the main thread.
state.current.events.get(42);
// New events create a new snapshot.
state.update('events', events =>
events.push('Upstream timeout')
);import { connectSharedSession }
from 'zerocopy/worker';
const shared = await connectSharedSession<Model>();
// No task. No per-read message.
const snapshot = shared.current;
const event = snapshot.events.get(42);
// This snapshot stays fixed across later updates.Find the error spike.
Keep new events coming.
Search and summarize 100,000 generated events. Freeze your investigation while ingestion continues. The UI and two reader workers share immutable columns.
Open the log explorerOne example of shared data—not a log-specific library.
// The same pattern works beyond logs.
const snapshot = shared.current;
// Read locally during a calculation.
const event = snapshot.events.get(42);
// Keep this snapshot while new data arrives.
// Publish new versions. Leave old reads intact.Big data. Busy interfaces.
Investigate without stopping.
Search, chart, and inspect a shared event stream. Keep a stable investigation while new events arrive.
Read the pattern →Keep editing. Keep context.
Run validation, layout, or export against an earlier document snapshot while the UI accepts new edits.
Read the pattern →One table. Several views.
Filter, group, and chart the same rows in independent workers. Keep the UI focused on visible results.
Read the pattern →Keep a large catalog shared.
Build facets, filters, and availability views over a large changing catalog—not a shared cart counter.
Read the pattern →Traverse a stable graph.
Share nodes and edges with dependency analysis, layout, and diagnostics workers while the graph changes.
Read the pattern →Inspect a world in motion.
Let analysis and visualization read published world snapshots. Keep one writer per arena.
Read the pattern →Don't benchmark
the marketing.
Compare zerocopy, Immutable.js Map, and Immer Map across workers. Choose the dataset and worker count. Run the actual code, check the output, and keep the raw samples.
Run a live benchmarkNo prefilled winner. No result sent to a server.
Real timings appear only after you run it.
Keep your stack.
Know the trade-offs.
Start with a collection. Bring your existing workers, Redux store, or message protocol. Add a task pool when you need one.
Find your starting point →Where zerocopy fits
Large, versioned collections that multiple threads need to read. Log explorers, editors, large tables, catalogs, graph tools, and simulations with a changing dataset.
What you need to know
Browsers need cross-origin isolation. Each arena has one allocating writer. Worker snapshots arrive asynchronously. Long-lived data needs an explicit compaction strategy.
Read the memory guide →When native collections are better
Small data that stays on one thread. Sharing avoids dataset copies; it does not make every collection operation faster or remove all allocations.
See the full recorded results →