DEV Community

Ghassen Ben Hadj Lassoued
Ghassen Ben Hadj Lassoued

Posted on

ComputeKit: A React Toolkit for Heavy Computations Without Freezing the UI

Hey everyone πŸ‘‹

I've been working on a side project called *ComputeKit *- a small library that makes it easier to run heavy computations in Web Workers with React hooks.

The problem I was trying to solve:

I was working on an app that needed to process images client-side, and my UI kept freezing. Setting up Web Workers manually was painful - separate files, postMessage boilerplate, managing state... it felt like too much ceremony for something that should be simple.

What I built:

// Register a heavy function once
kit.register('processData', (data) => {
// This runs in a Web Worker, not the main thread
return heavyComputation(data);
}); 

// Use it like any other async operation
const { data, loading, error, run } = useCompute('processData');
Enter fullscreen mode Exit fullscreen mode

Features:

  • React hooks with loading/error states out of the box

  • Automatic worker pool (uses available CPU cores)

  • Optional WASM support for extra performance

  • TypeScript support

  • ~3KB gzipped

What I'm looking for:

  • Honest feedback - is this useful or am I solving a problem nobody has?

  • Bug reports if you try it

  • Ideas for improvements

  • Contributors welcome if anyone's interested!

Links:

This is my first open source library so I'd really appreciate any feedback, even if it's "this already exists" or "you're doing X wrong". Thanks for reading! πŸ™

Top comments (0)