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

vite-plugin-sveltekit-node-worker

v1.1.2

Published

Vite plugin for Node.js worker_threads in SvelteKit 3 with adapter-node.

Readme

vite-plugin-sveltekit-node-worker

Vite plugin that bundles Node.js worker_threads for SvelteKit 3 with adapter-node.

Import a worker with ?nodeWorker. The plugin bundles it with esbuild and returns a Worker subclass you can new.

It works in both development and production.

Installation

SvelteKit 3 is currently published as next (beta). This plugin needs that and adapter-node:

npm install @sveltejs/kit@next @sveltejs/adapter-node@next
npm install -D vite-plugin-sveltekit-node-worker

Usage

Add the plugin next to sveltekit():

import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vite";
import { sveltekitNodeWorker } from "vite-plugin-sveltekit-node-worker";

export default defineConfig({
  plugins: [sveltekit(), sveltekitNodeWorker()],
});

Match adapter-node's out if you change it:

sveltekitNodeWorker({ out: "dist" });

Write a worker, then import it with ?nodeWorker:

// src/lib/server/heavy.ts
import { parentPort } from "node:worker_threads";

parentPort?.on("message", (n: number) => {
  parentPort?.postMessage(n * 2);
});
// src/lib/server/spawner.ts
import Worker from "./heavy.ts?nodeWorker";

const worker = new Worker();
worker.postMessage(21);
worker.on("message", (result) => {
  console.log(result); // 42
});

The default export is a class that extends node:worker_threads.Worker and always spawns with { type: "module" }. Pass extra Worker options to the constructor if needed.

Client builds get export default null — Node workers only run on the server.

Worker modules

Worker source can import:

  • #lib/... — resolved to src/lib (SvelteKit 3 subpath imports)
  • $app/env/private and $app/env/public — shims from src/env.ts / src/env.js (defineEnvVars, including public and static)

.env files load in Vite order: .env.[mode].local, .env.[mode], .env.local, .env.

Dev vs production

Dev (vite dev): workers build to .svelte-kit/node-workers and spawn from that path. Changing a worker file or src/env rebuilds and full-reloads.

Production (vite build + adapter-node): the worker file is written next to the SSR chunk that imported it. After the adapter re-bundles, the plugin copies it beside any server chunk that references it under out (default build).

Source Code

Since this plugin is MIT licensed, you can also contribute to it at it's repo on GitHub