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

elysia-sveltekit

v1.0.2

Published

Server hook adapter bridging the Elysia web framework with SvelteKit

Readme

elysia-sveltekit

A strictly type-safe server hook adapter for bridging the Elysia web framework with SvelteKit.

This adapter allows you to seamlessly integrate an Elysia backend directly into your SvelteKit application's hooks.server.ts. It provides a factory function that creates an Elysia app instance and automatically maps SvelteKit's RequestEvent context (like locals and platform) into Elysia's lifecycle.

Features

  • Type-Safe Context Injection: Pass SvelteKit's locals, platform, or any custom data directly into your Elysia endpoints.
  • No Global State: State is safely encapsulated within a factory closure using a WeakMap.
  • Zero Boilerplate: Returns a native SvelteKit Handle function ready to be exported from hooks.server.ts.
  • Native Types: Leverages SvelteKit's native @sveltejs/kit types.

Installation

bun add elysia elysia-sveltekit

Usage

1. Initialize the Adapter & Define your API

Create your Elysia application and define the context mapping. The sveltekit factory returns both the Elysia app and the SvelteKit hook.

// src/lib/server/api.ts
import { sveltekit } from "elysia-sveltekit";

// 1. Define the context you want to inject
interface MyContext {
  locals: App.Locals;
  platform: App.Platform;
}

// 2. Initialize the adapter
export const { app, hook: handleApi } = sveltekit<MyContext, "/api">(
  (event) => ({
    locals: event.locals,
    platform: event.platform,
  }),
  { prefix: "/api" }, // The path prefix your Elysia app will listen on
);

// 3. Build your API endpoints
export const api = app.get("/hello", ({ locals, platform }) => {
  return {
    message: "Hello from Elysia!",
    user: locals.user, // Strongly typed!
  };
});

2. Connect the SvelteKit Hook

In your SvelteKit hooks.server.ts, simply export the generated hook.

// src/hooks.server.ts
import { handleApi } from "$lib/server/api";
import type { Handle } from "@sveltejs/kit";

export const handle: Handle = handleApi;

License

MIT