MCPcopy Index your code
hub / github.com/danielroe/nuxt-workers

github.com/danielroe/nuxt-workers @v0.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.0 ↗ · + Follow
22 symbols 50 edges 13 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Nuxt Workers

npm version npm downloads Github Actions Codecov

SSR-safe, zero-config Web Workers integration for Nuxt.

Web Workers enable running JavaScript code in the background to perform complex tasks without blocking the main thread, ensuring smoother and more responsive web applications.

Read more about Web Workers.

Features

  • 🔥 SSR-safe usage of Web Workers
  • ✨ auto-imported, zero-configuration
  • 💪 fully typed

Quick Setup

Install and add nuxt-workers to your nuxt.config.

npx nuxi@latest module add nuxt-workers

That's it! You can add web workers in your Nuxt app ✨

Usage

Create your web worker in the ~/workers/ directory. It should export any utilities you want to be usable elsewhere:

// workers/hi.ts
export function hi() {
  return 'Hello from web worker!'
}

Then, call it in the rest of your Vue app.

<script setup lang="ts">
const message = await hi()
</script>

<template>



    {{ message }}



</template>

[!TIP] Even if your function is synchronous, it will always become async when it is called within a worker because communication with a worker will always be asynchronous.

Roadmap

  • [x] 📖 basic documentation
  • [x] 🧪 client-side test
  • [ ] 🧱 useNuxtWorker composable for more fine-grained control
  • [ ] ⚗️ automatic deduplicating on client-side
  • [ ] 📦 webpack support
  • [ ] ⚠️ type-level + dev warning if non serialisable args are passed
  • [ ] 🤝 automatic shared workers with .shared.ts suffix
  • [ ] 💤 worker auto-shutdown

💻 Development

  • Clone this repository
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Stub module with pnpm dev:prepare
  • Run pnpm dev to start playground in development mode

License

Made with ❤️

Published under the MIT License.

Extension points exported contracts — how you extend this code

ModuleOptions (Interface)
(no doc)
src/module.ts
WorkerPluginOptions (Interface)
(no doc)
src/plugins/unplugin.ts

Core symbols most depended-on inside this repo

WorkerPlugin
called by 3
src/plugins/unplugin.ts
initWorker
called by 2
test/__snapshots__/auto-import.client.js
WorkerTransformPlugin
called by 2
src/plugins/unplugin.ts
setup
called by 1
src/module.ts
foo
called by 0
test/__snapshots__/auto-import.client.js
bar
called by 0
test/__snapshots__/auto-import.client.js
foo
called by 0
test/__snapshots__/worker.client.js
bar
called by 0
test/__snapshots__/worker.client.js

Shape

Function 20
Interface 2

Languages

TypeScript100%

Modules by API surface

src/plugins/unplugin.ts6 symbols
src/module.ts4 symbols
test/__snapshots__/worker.client.js3 symbols
test/__snapshots__/auto-import.client.js3 symbols
test/transform.spec.ts2 symbols
test/__snapshots__/auto-import.server.js2 symbols
playground/workers/test.ts1 symbols
playground/layers/test/workers/layer-worker.ts1 symbols

For agents

$ claude mcp add nuxt-workers \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact