0.2.0 • Published 2 years ago
next-worker v0.2.0
next-worker
Makes it simple to create and manage Web Workers in NextJS. Detects imports to *.worker.[js|ts]
and manages the hard stuff for you.
Caution: This package is still under development.
Without next-worker
:
useEffect(() => {
worker = new Worker(new URL('./bg-task.js', import.meta.url));;
}, []);
With next-worker
:
import worker from './bg-task.worker.js'
Usage
In your next.config.json
:
module.exports = {
webpack: config => {
config.module.rules.push({
test: /\.worker\.js$/,
use: [{ loader: 'next-worker' }]
});
}
}