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

@teovilla/code-runner-react

v0.4.2

Published

Browser real-time SDK for the code-runner service: a CodeRunnerProvider + useCodeRunnerJob hook that subscribes to private-run-<jobId> over soketi (pusher-js) and reassembles ordered stdout/stderr.

Downloads

0

Readme

@teovilla/code-runner-react

The browser real-time SDK for the code-runner service.

  • <CodeRunnerProvider> — one pusher-js client wired to your self-hosted soketi.
  • useCodeRunnerJob(...) — subscribe to a job's private-run-<jobId> channel and get ordered stdout / stderr, the current stage, and the terminal result.

Output-only and token-free. This package never holds the code-runner bearer token. It receives live output over soketi, and delegates actions (stdin / kill) to callbacks that hit your backend — which uses @teovilla/code-runner-sdk-node.

Install

npm i @teovilla/code-runner-react react pusher-js

react (>=18) and pusher-js (>=8) are peer dependencies you provide.

Quickstart

1. Wrap your app

import { CodeRunnerProvider } from "@teovilla/code-runner-react";

export function App({ children }: { children: React.ReactNode }) {
  return (
    <CodeRunnerProvider
      appKey={import.meta.env.VITE_SOKETI_APP_KEY}
      host="localhost"
      port={6001}
      useTLS={false}
      // your backend route that signs the private-channel auth with sdk-node's
      // createChannelAuthorizer (the soketi APP_SECRET lives only there)
      authEndpoint="/channel-auth"
    >
      {children}
    </CodeRunnerProvider>
  );
}

2. Subscribe to a job

import { useCodeRunnerJob } from "@teovilla/code-runner-react";

function JobView({ jobId }: { jobId: string }) {
  const { stage, stdout, stderr, result, status, sendStdin, kill } =
    useCodeRunnerJob({
      jobId,
      // The browser has no token. These call back into YOUR backend, which
      // uses @teovilla/code-runner-sdk-node to talk to the gateway.
      onStdin: (chunk) =>
        fetch(`/api/jobs/${jobId}/stdin`, {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify({ chunk }),
        }),
      onKill: () => fetch(`/api/jobs/${jobId}/kill`, { method: "POST" }),
    });

  return (
    <div>
      <div>stage: {stage ?? "—"} · status: {status}</div>
      <pre>{stdout}</pre>
      <pre style={{ color: "crimson" }}>{stderr}</pre>
      <button onClick={() => sendStdin("hello\n")}>send stdin</button>
      <button onClick={() => kill()}>kill</button>
      {result && (
        <div>
          exit {String(result.exitCode)} · {result.durationMs}ms
          {result.timedOut && " · timed out"}
          {result.truncated && " · output truncated"}
        </div>
      )}
    </div>
  );
}

stdout / stderr are reassembled in seq order from the worker's chunks, so they always render correctly even if soketi delivers out of order.

The full circle

sequenceDiagram
    participant B as Browser (this SDK)
    participant Y as Your backend (sdk-node)
    participant CR as code-runner gateway
    participant SK as soketi
    Y->>CR: execute() + start()  (bearer token)
    Y-->>B: { jobId }
    B->>Y: authorize private-run-id (authEndpoint)
    Y-->>B: signed auth (APP_SECRET stays server-side)
    B->>SK: subscribe private-run-id
    SK-->>B: stage / stdout / stderr / result
    B->>Y: sendStdin / kill
    Y->>CR: forward to gateway
  1. Your backend enqueues + starts a job with @teovilla/code-runner-sdk-node and returns { jobId }.
  2. The browser calls useCodeRunnerJob({ jobId }); pusher-js authorizes the private-run-<jobId> subscription against your authEndpoint, which signs with sdk-node's createChannelAuthorizer.
  3. Live stage / stdout / stderr / result events stream in.
  4. sendStdin / kill post to your backend, which forwards to the gateway via sdk-node.

The bearer token and soketi APP_SECRET never leave the server.

License

MIT