npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-worker-bridge

v0.1.1

Published

Zero-boilerplate reactive bridge for Angular Dedicated and Shared Workers.

Downloads

26

Readme

ngx-worker-bridge

A lightweight, zero-boilerplate reactive bridge for Angular and React that makes Web Workers (Dedicated and Shared) as simple as calling a regular method.

npm version license

Why?

Web Workers have a verbose API (postMessage, onmessage, manual serialization). This library removes all of that. Just decorate a method with @RunInWorker — the rest is handled for you.

Installation

Angular (RxJS is already included in Angular projects):

npm i ngx-worker-bridge

React (RxJS must be installed separately since React doesn't include it):

npm i ngx-worker-bridge rxjs

React only: Add these to your tsconfig.app.json for decorator support:

{ "experimentalDecorators": true, "useDefineForClassFields": false }

Core Concept

| Thread | Your Code | |---|---| | Worker thread | A plain TypeScript class (Module) with your business logic | | Main thread | A service/component that calls methods as if they're local |

The library handles the postMessage bridge between them invisibly.


Angular Quick Start

1. Worker file (app.worker.ts)

import { startWorker } from 'ngx-worker-bridge';
import { DataModule } from './data.module';

startWorker([DataModule]);

2. Bootstrap (main.ts)

import { provideWorkerBridge } from 'ngx-worker-bridge/angular';

bootstrapApplication(AppComponent, {
  providers: [
    provideWorkerBridge({
      instance: new Worker(new URL('./app.worker', import.meta.url), { type: 'module' }),
      modules: [DataModule]
    }),
    // Optional: add a SharedWorker for multi-tab state
    provideWorkerBridge({
      name: 'shared',
      instance: new SharedWorker(new URL('./app.worker', import.meta.url), { name: 'shared', type: 'module' }),
      modules: [DataModule]
    })
  ]
});

3. Service

import { Injectable } from '@angular/core';
import { RunInWorker, workerStore } from 'ngx-worker-bridge';

@Injectable({ providedIn: 'root' })
export class DataService {
  // Reactive state — updates automatically when the worker calls setState()
  count$ = workerStore<number>('counter', 'shared');

  // This runs in the worker — UI thread is never blocked
  @RunInWorker({ bridge: 'shared', namespace: 'data' })
  processData(payload: any): Promise<any> { return null as any; }
}

React Quick Start

1. Worker file (app.worker.ts)

import { startWorker } from 'ngx-worker-bridge';
import { DataModule } from './data.module';

startWorker([DataModule]);

2. Bootstrap (App.tsx or main.tsx)

import { bootstrapWorker } from 'ngx-worker-bridge';
import { DataModule } from './data.module';

bootstrapWorker({
  worker: new SharedWorker(new URL('./app.worker', import.meta.url), { name: 'shared', type: 'module' }),
  name: 'shared',
  modules: [DataModule]
});

3. Component

import { useWorkerStore } from 'ngx-worker-bridge/react';
import { RunInWorker } from 'ngx-worker-bridge';

class DataService {
  @RunInWorker({ bridge: 'shared', namespace: 'data' })
  processData(payload: any): Promise<any> { return null as any; }
}

const service = new DataService();

function App() {
  const count = useWorkerStore<number>('counter', 'shared');
  return <button onClick={() => service.processData({})}>Count: {count}</button>;
}

Worker Module

Your background logic lives in a plain TypeScript class. Use setState to push reactive updates to all connected tabs.

import { setState } from 'ngx-worker-bridge';

export class DataModule {
  private count = 0;

  // Namespace matches the class name: "DataModule" → "data"
  increment() {
    this.count++;
    setState('counter', this.count); // broadcasts to all tabs
    return this.count;
  }
}

Best Use Cases

  • Multi-Tab State Sync — Use a SharedWorker to keep counters, notifications, or live data in sync across all open tabs without any server involvement.
  • CPU Offloading — Move heavy computation (large JSON processing, sorting, math) off the UI thread so your app stays interactive.
  • Shared Connections — Maintain a single WebSocket or polling interval in a SharedWorker and broadcast to all connected tabs.

Debugging

All console.log, console.warn, and console.error calls made inside your worker modules are automatically forwarded to the main browser console, prefixed with [Worker]. No setup required.


Demo

Demo Repository (Angular) [Demo Repository (React)] (https://github.com/yashwantyashu/worker-react-demo)