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

bun-socks

v1.0.1

Published

Zero-dependency SOCKS5 fetch client for Bun, supporting HTTP/HTTPS, custom headers, and chunked encoding.

Readme

bun-socks

CI npm version License: MIT

A lightweight, zero-dependency SOCKS5 proxy client specifically designed for Bun.

While Bun's native fetch supports HTTP proxies, it does not currently support SOCKS5. This library bridges that gap by implementing a custom fetch wrapper that handles SOCKS5 handshakes (RFC 1928) and manually upgrades sockets to TLS for HTTPS requests.

Table of Contents

Features

  • 🚀 Zero Dependencies: Uses Bun/Node native net and tls modules.
  • 🔒 SOCKS5 Support: Full handshake with Username/Password authentication (RFC 1929).
  • 🌐 HTTPS Support: Manually upgrades raw TCP sockets to TLS for secure connections.
  • 📦 Native Experience: API mimics the standard fetch exactly.
  • Streaming: Supports chunked transfer encoding and binary responses.

Installation

bun add bun-socks

Usage

Import fetch from the library and use the proxy option in the init object. The proxy connection string must follow the format: socks5://user:pass@host:port.

Examples

Basic GET Request

import { fetch } from "bun-socks";

const response = await fetch("https://api.ipify.org?format=json", {
  proxy: "socks5://myuser:[email protected]:1080"
});

const data = await response.json();
console.log(data);

POST Request with Custom Headers

import { fetch } from "bun-socks";

const response = await fetch("https://example.com/api/data", {
  method: "POST",
  body: JSON.stringify({ key: "value" }),
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer token"
  },
  proxy: "socks5://user:[email protected]:1080"
});

Using alongside standard Fetch

If you omit the proxy option, the library falls back to the native global fetch, so you can use it as a drop-in replacement throughout your application.

// Uses SOCKS5 proxy
await fetch("https://secret-service.com", { proxy: "socks5://..." });

// Uses standard internet connection (native fetch)
await fetch("https://google.com"); 

API

fetch(input: string | URL | Request, init?: RequestInit & { proxy?: string }): Promise<Response>

A custom fetch function that supports SOCKS5 proxies via the proxy option.

  • Parameters:
    • input: The URL or Request object to fetch.
    • init: Optional init object, extended with proxy string for SOCKS5 URL.
  • Returns: A Promise that resolves to a Response object.
  • Throws: Errors for invalid proxy URLs or connection failures.

If no proxy is provided, it falls back to the native globalThis.fetch.

Configuration

The proxy URL must be a valid SOCKS5 URI:

  • No Auth: socks5://127.0.0.1:9050
  • With Auth: socks5://user:[email protected]:1080
  • IPv6: socks5://user:password@[2001:db8::1]:1080

License

MIT