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

@nprpc/adapter-sveltekit

v1.0.0

Published

SvelteKit adapter for NPRPC - serves SSR via shared memory IPC

Readme

@nprpc/adapter-sveltekit

A SvelteKit adapter that serves SSR (Server-Side Rendering) via shared memory IPC with an NPRPC C++ server.

Overview

This adapter enables high-performance SSR by:

  1. Building your SvelteKit app for production
  2. Creating a Node.js handler that communicates via shared memory
  3. The C++ NPRPC server handles HTTP requests and forwards them to the Node.js handler
  4. Responses are returned through the same shared memory channel

This eliminates HTTP overhead for SSR, achieving near-native performance.

Installation

npm install @nprpc/adapter-sveltekit

Usage

svelte.config.js

import adapter from '@nprpc/adapter-sveltekit';

export default {
    kit: {
        adapter: adapter({
            // Optional: output directory (default: 'build')
            out: 'build',
            
            // Optional: fixed channel ID (default: from environment)
            channelId: 'my-app-channel',
            
            // Optional: precompress static assets (default: true)
            precompress: true
        })
    }
};

Building

npm run build

Running

The built app expects a C++ NPRPC server to be running with the shared memory channel:

# Set the channel ID (if not using fixed channelId in config)
export NPRPC_CHANNEL_ID=my-app-channel

# Start the Node.js handler
node build/index.js

Architecture

┌─────────────────┐     HTTP      ┌───────────────────┐
│     Browser     │ ◄──────────►  │  NPRPC C++ Server │
└─────────────────┘               └────────┬──────────┘
                                           │
                                    Shared Memory
                                           │
                                  ┌────────▼────────┐
                                  │  SvelteKit SSR  │
                                  │   (Node.js)     │
                                  └─────────────────┘

Request Flow

  1. Browser sends HTTP request to C++ server
  2. C++ server serializes request to JSON
  3. Request sent via shared memory to Node.js
  4. SvelteKit processes request (SSR)
  5. Response sent back via shared memory
  6. C++ server returns HTTP response to browser

Message Format

C++ Server Integration

The C++ server needs to:

  1. Create a shared memory channel with SharedMemoryChannel
  2. For SSR requests, serialize the HTTP request to JSON
  3. Send via shared memory and wait for response
  4. Deserialize response and return to client

Example (simplified):

#include <nprpc/impl/shared_memory_channel.hpp>
#include <nlohmann/json.hpp>

class SsrHandler {
    nprpc::impl::SharedMemoryChannel channel_;
    
public:
    SsrHandler(boost::asio::io_context& ioc, const std::string& channel_id)
        : channel_(ioc, channel_id, true, true)  // server, create
    {}
    
    std::string handle_ssr_request(
        const std::string& method,
        const std::string& url,
        const std::map<std::string, std::string>& headers,
        const std::string& body
    ) {
        // Serialize request
        nlohmann::json req = {
            {"type", "request"},
            {"id", next_request_id_++},
            {"method", method},
            {"url", url},
            {"headers", headers},
            {"body", base64_encode(body)}
        };
        
        // Send and wait for response
        channel_.send(req.dump());
        // ... wait for response ...
        
        return base64_decode(response["body"]);
    }
};

Performance

Shared memory IPC provides:

  • Zero network overhead - No TCP/HTTP stack for SSR
  • ~1+ GB/s throughput - Limited only by memory bandwidth
  • Sub-millisecond latency - Direct memory access

License

MIT