⚡ Something like react server components, but web workers instead of a server

Overview

react-worker-components-plugin

something like react server components, but web workers instead of a server

react-worker-components-plugin is a plugin that renders components in web workers and not in the main thread, which helps in rendering blocking components in a non-blocking way. This project is based on the experimental react-worker-components.

  • Fast
  • 💥 Powered by Suspense
  • 🔥 Easy to use

You just need to create a file with a name that contains .worker., in case you want to render its components in a Worker.

Example

Try online (Stackblitz)

Fib.worker.tsx

const fib = (i: number): number => {
  const result = i <= 1 ? i : fib(i - 1) + fib(i - 2);
  return result;
};

export const Fib = ({ num, children }) => {
  const fibNum = fib(num); 

  return (
    <div>
      <span>fib of number {num}: {fibNum}</span>
      {children}
    </div>
  );
};

App.tsx

setCount(count + 1)}> +1 Loading...
}> ); } export default App; ">
import { Fib } from './Fib.worker'

function App() {
  const [count, setCount] = useState(40);
  return (
    <div>
      <h1>Workers</h1>
      <span>Count: {count}</span>
      <button id="increment" type="button" onClick={() => setCount(count + 1)}>
        +1
      </button>
      <button
        id="decrement"
        type="button"
        onClick={() => setCount((c) => c - 1)}
      >
        -1
      </button>
      <Suspense fallback={<div>Loading...</div>}>
	      <Fib num={count} />
      </Suspense>
    </div>
  );
}

export default App;

chrome-capture

Install

npm install -D react-worker-components-plugin

Plugins

Vite

This plugin for now works in Vite, and it's tested properly there.

// vite.config.js
import { defineConfig } from "vite";
import { vite as rwc } from "react-worker-components-plugin";

export default defineConfig({
 plugins: [rwc()]
});

Next/Webpack/...

It's planned to support other bundlers, any help is appreciated in that case!

Contributing

Please try the plugin, find issues, report and fix them by sending Pull requests and issues! I appreciate that.

You might also like...

Mobile app development framework and SDK using HTML5 and JavaScript. Create beautiful and performant cross-platform mobile apps. Based on Web Components, and provides bindings for Angular 1, 2, React and Vue.js.

Mobile app development framework and SDK using HTML5 and JavaScript. Create beautiful and performant cross-platform mobile apps. Based on Web Components, and provides bindings for Angular 1, 2, React and Vue.js.

Onsen UI - Cross-Platform Hybrid App and PWA Framework Onsen UI is an open source framework that makes it easy to create native-feeling Progressive We

Jan 8, 2023

Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React.

Recoil · Recoil is an experimental set of utilities for state management with React. Please see the website: https://recoiljs.org Installation The Rec

Jan 8, 2023

React components for efficiently rendering large lists and tabular data

React components for efficiently rendering large lists and tabular data

React components for efficiently rendering large lists and tabular data. Check out the demo for some examples. Sponsors The following wonderful compan

Jan 7, 2023

Bootstrap components built with React

React-Bootstrap Bootstrap 4 components built with React. Docs See the documentation with live editable examples and API documentation. To find the doc

Jan 5, 2023

⚡️ Simple, Modular & Accessible UI Components for your React Applications

⚡️ Simple, Modular & Accessible UI Components for your React Applications

Build Accessible React Apps with Speed ⚡️ Chakra UI provides a set of accessible, reusable, and composable React components that make it super easy to

Jan 4, 2023

React components for efficiently rendering large lists and tabular data

React components for efficiently rendering large lists and tabular data

react-window React components for efficiently rendering large lists and tabular data React window works by only rendering part of a large data set (ju

Jan 4, 2023

Simple React Bootstrap 4 components

Simple React Bootstrap 4 components

reactstrap Stateless React Components for Bootstrap 4. Getting Started Follow the create-react-app instructions to get started and then follow the rea

Jan 5, 2023

🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.

🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.

downshift 🏎 Primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components. Read the docs | See

Dec 28, 2022

React UI Components for macOS High Sierra and Windows 10

React UI Components for macOS High Sierra and Windows 10. npm install react-desktop --save Help wanted! I am looking for developers to help me develop

Dec 24, 2022
Owner
M. Bagher Abiat
Member of @pmndrs, @vikejs & @vitest-dev
M. Bagher Abiat
📢 Easily get notified when something in Directus happens.

Directus LogSnag ?? Get notified when something in Directus happens. What is LogSnag? LogSnag is a simple event tracking tool. It helps you keep track

Conner 14 Sep 5, 2022
A React utility belt for function components and higher-order components.

A Note from the Author (acdlite, Oct 25 2018): Hi! I created Recompose about three years ago. About a year after that, I joined the React team. Today,

Andrew Clark 14.8k Jan 4, 2023
Nextjs-components: A collection of React components

nextjs-components A collection of React components, transcribed from https://vercel.com/design. 1 Motivation Blog post from 01/09/2022 Todo's Unit tes

null 94 Nov 30, 2022
Word guessing game like Wordle but to compete with your friends

Battle your friends in a word guessing game WarWordly is an Open Source and Free to Play multiplayer game inspired in the famous Wordle. The idea is t

Nico Andrade 28 Dec 7, 2022
Providing accessible components with Web Components & Material You

tiny-material Still on developing, DO NOT use for production environment Run well on Google Chrome, Firefox, Chrome for Android, Microsoft Edge (Chrom

HugePancake 11 Dec 31, 2022
React components and hooks for creating VR/AR applications with @react-three/fiber

@react-three/xr React components and hooks for creating VR/AR applications with @react-three/fiber npm install @react-three/xr These demos are real,

Poimandres 1.4k Jan 4, 2023
A react component available on npm to easily link to your project on github and is made using React, TypeScript and styled-components.

fork-me-corner fork-me-corner is a react component available on npm to easily link to your project on github and is made using React, TypeScript and s

Victor Dantas 9 Jun 30, 2022
a fork version of vitesse-webext, but with react

@aiou/webext-template a fork version of vitesse-webext, but with react A Vite powered WebExtension (Chrome, FireFox, etc.) starter template. Edit on S

ruaaa 12 Dec 2, 2022
we are make our components in story book. So if we add some components you can find document and example of useage in storybook.

we are make our components in story book. So if we add some components you can find document and example of useage in storybook.

고스락 6 Aug 12, 2022
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!

Build bulletproof UI components faster Storybook is a development environment for UI components. It allows you to browse a component library, view the

Storybook 75.8k Jan 4, 2023