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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@iasd/kit-di

v1.0.0

Published

<p align="center"> <img src="https://repository-images.githubusercontent.com/1047452352/3655e653-07d7-4fbd-b0fb-a590c59635ca" alt="logo"/> </p>

Readme

KitDi

A lightweight, dependency free, open source, dependency injection container for SvelteKit with support for global and request-scoped providers.

  • ⚡ Global & Request scopes
  • 🧩 Discoverable Module files
  • 🔄 Class, value, factory & async factory providers
  • ✅ Synchronous inject() with TypeScript support

Installation

# Install via npm, bun, ...etc
bun add @iasd/kit-di

Quick Start

1) Define a module

    // src/feature/feature.module.ts
    import { Module, provide, InjectionToken } from "kit-di";

    export const Env = new InjectionToken<{ nodeEnv: string }>("Env");

    export class FeatureService {}

    export default new Module({
      providers: [
        // Global value
        provide({ provide: Env, useValue: { nodeEnv: process.env.NODE_ENV ?? "development" } }),

        // Global class
        provide({ provide: FeatureService, useClass: FeatureService }),

        // Request-scoped factory (new per request)
        provide({
          scope: "REQUEST",
          provide: new InjectionToken<Date>("RequestStart"),
          useFactory: () => new Date(),
        }),
      ],
    });

2) Wire it into SvelteKit

    // src/hooks.server.ts
    import type { Handle } from "@sveltejs/kit";
    import { KitDi } from "kit-di";

    const modules = await KitDi.discover();
    await modules.register();          // resolve GLOBAL providers once at startup

    export const handle: Handle = modules.handle(); // per-request DI context

Using more handlers? Wrap with sequence(modules.handle(), yourOtherHandle).

3) Inject dependencies where you need them

    // src/routes/+page.server.ts
    import { inject } from "kit-di";
    import { FeatureService, Env } from "../feature/feature.module";

    export const load = async () => {
      const svc = inject(FeatureService);  // class instance
      const env = inject(Env);             // token-bound value
      return { env, id: svc.id };
    };

Defining Providers

Providers can be created with provide(...):

  • Value
    Bind a concrete value to an InjectionToken.

  • Class
    The injector constructs the class (lazy by default, or eager with eager: true).

  • Factory (sync)
    A function returning a value (lazy by default).

  • Factory (async)
    A function returning a Promise — must use eager: true so it resolves during startup/request.
    This keeps inject() strictly synchronous.

Scope options:

  • "GLOBAL" (default): singleton for the whole app
  • "REQUEST": new instance per request (only available during the request lifecycle)

Contributing

If you would like to contribute, take a look at the contribution guide.

License

KitDi is licensed under the MIT License.