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

@outray/core

v0.0.1

Published

Core tunnel client for Outray - shared between CLI and framework plugins

Readme

@outray/core

Core tunnel client for Outray - shared between the CLI and framework plugins.

This package provides the low-level WebSocket client for establishing tunnels to the Outray server. It's used internally by:

  • outray (CLI)
  • @outray/vite (Vite plugin)
  • Other framework integrations

Installation

npm install @outray/core
# or
pnpm add @outray/core
# or
yarn add @outray/core

Usage

import { OutrayClient } from '@outray/core';

const client = new OutrayClient({
  localPort: 3000,
  
  // Optional: API key for authentication
  apiKey: process.env.OUTRAY_API_KEY,
  
  // Optional: Request a specific subdomain
  subdomain: 'my-app',
  
  // Callbacks
  onTunnelReady: (url) => {
    console.log(`Tunnel ready at: ${url}`);
  },
  
  onError: (error, code) => {
    console.error(`Error: ${error.message}`);
  },
  
  onRequest: (info) => {
    console.log(`${info.method} ${info.path} - ${info.statusCode} (${info.duration}ms)`);
  },
  
  onReconnecting: (attempt, delay) => {
    console.log(`Reconnecting in ${delay}ms (attempt ${attempt})`);
  },
});

// Start the tunnel
client.start();

// Check status
console.log('Connected:', client.isConnected());
console.log('URL:', client.getUrl());

// Stop when done
client.stop();

API

OutrayClient

Constructor Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | localPort | number | required | Local port to proxy requests to | | serverUrl | string | 'wss://api.outray.dev/' | Outray server WebSocket URL | | apiKey | string | - | API key for authentication | | subdomain | string | - | Subdomain to use (requires auth) | | customDomain | string | - | Custom domain (must be configured in dashboard) | | protocol | 'http' \| 'tcp' \| 'udp' | 'http' | Tunnel protocol type | | remotePort | number | - | Remote port for TCP/UDP tunnels | | onTunnelReady | (url: string, port?: number) => void | - | Called when tunnel is established | | onError | (error: Error, code?: string) => void | - | Called on error | | onClose | (reason?: string) => void | - | Called when tunnel closes | | onReconnecting | (attempt: number, delay: number) => void | - | Called before reconnect | | onRequest | (info: RequestInfo) => void | - | Called for each proxied request |

Methods

| Method | Returns | Description | |--------|---------|-------------| | start() | void | Start the tunnel connection | | stop() | void | Stop the tunnel and cleanup | | getUrl() | string \| null | Get the assigned tunnel URL | | isConnected() | boolean | Check if currently connected |

Protocol Utilities

import { encodeMessage, decodeMessage } from '@outray/core';

// Encode a message to send
const encoded = encodeMessage({ type: 'open_tunnel', apiKey: '...' });

// Decode a received message
const message = decodeMessage(rawData);

Error Codes

import { ErrorCodes } from '@outray/core';

// Available error codes:
ErrorCodes.SUBDOMAIN_IN_USE
ErrorCodes.AUTH_FAILED
ErrorCodes.LIMIT_EXCEEDED
ErrorCodes.INVALID_SUBDOMAIN
ErrorCodes.CUSTOM_DOMAIN_NOT_CONFIGURED

Building Framework Plugins

If you're building a framework plugin, use @outray/core as the foundation:

import { OutrayClient, type OutrayClientOptions } from '@outray/core';

export function myFrameworkPlugin(options: MyPluginOptions) {
  let client: OutrayClient | null = null;
  
  return {
    onServerStart(port: number) {
      client = new OutrayClient({
        localPort: port,
        apiKey: options.apiKey,
        onTunnelReady: (url) => {
          // Display URL in framework's style
        },
        onError: (error) => {
          // Handle errors appropriately
        },
      });
      
      client.start();
    },
    
    onServerStop() {
      client?.stop();
    },
  };
}

License

MIT © akinloluwami