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

std-osc8

v0.1.0

Published

Detect terminal hyperlink capabilities of the active terminal from environmental variables

Readme

std-osc8

npm version License: MIT TypeScript

Detect terminal hyperlink (OSC8) support and emit hyperlinks (or graceful fallbacks). A focused, sync, ESM-only complement to unjs/std-env. Zero runtime dependencies.

import { link } from "std-osc8";

console.log(link("the docs", "https://example.com"));
// In an OSC8-supporting terminal (iTerm, WezTerm, kitty, Konsole, …):
//   the docs       ← a clickable hyperlink
// In a non-supporting terminal, inside tmux without passthrough,
// in CI, or when stdout is piped to a file:
//   the docs (https://example.com)

std-osc8 does the detection for you. You write link(label, url) once, and it picks the right rendering across iTerm2, WezTerm, kitty, VS Code, Windows Terminal, GNOME Terminal, Konsole, mintty, and 13 other identifiable terminals — falling back to plain text inside tmux / screen, in CI, when stdout is piped, or when NO_COLOR is set.

Install

pnpm add std-osc8
# or
npm install std-osc8

At a glance

import {
  link,
  openHyperlink,
  closeHyperlink,
  supportsHyperlinks,
  supportsHyperlinksStderr,
  supportsHyperlinksFor,
  osc8,
} from "std-osc8";

// Most common: render a hyperlink with automatic fallback
link("docs", "https://example.com");

// Boolean check — eager, computed once at module import (for stdout)
if (supportsHyperlinks) {
  // emit fancy output
}

// Per-stream check — function form, accepts WriteStream-like or numeric fd
supportsHyperlinksFor(process.stderr); // boolean
supportsHyperlinksFor(2);              // boolean

// Diagnostic info — what was detected and why
osc8.terminal;        // "iTerm.app" | "WezTerm" | "kitty" | … | null
osc8.terminalVersion; // "3.5.0" | … | null
osc8.reason;          // "terminal-known-supported" | "wrapper-strips" | "not-a-tty" | …
osc8.capabilities;    // { params, fileUrls, fileUrlsRemoteUnsafe }
osc8.wrapper;         // { name: "tmux" | "screen", passesThrough } | null

// Streaming open/close pair — for progress bars, word-wrapped labels,
// anything where the linked text is built up across multiple writes
process.stdout.write(openHyperlink("https://example.com", { id: "n1" }));
process.stdout.write("docs");
process.stdout.write(closeHyperlink());

Full surface in the API reference.

Customizing the fallback

link("docs", "https://example.com");
//   "docs (https://example.com)"   ← default ("with-url")

link("docs", "https://example.com", { fallback: "label-only" });
//   "docs"

link("docs", "https://example.com", { fallback: "url-only" });
//   "https://example.com"

link("docs", "https://example.com", {
  fallback: (label, url) => `[${label}](${url})`, // markdown-ish
});
//   "[docs](https://example.com)"

You can also force the rendering decision with enabled:

link("docs", "https://example.com", { enabled: true });  // always emit OSC8
link("docs", "https://example.com", { enabled: false }); // always use fallback

Override env vars

| Variable | Effect | | --- | --- | | FORCE_HYPERLINK=1 | Force on. Overrides not-a-tty and wrapper checks. | | NO_HYPERLINK=1 | Force off. | | NO_COLOR=1 | Force off (per no-color.org spec, any non-empty value is truthy — including "0"). |

Precedence: FORCE_HYPERLINK > NO_HYPERLINK > NO_COLOR > not-a-TTY > wrapper > terminal allowlist.

See Detection Algorithm for the full 7-rule ladder and the rationale per rule.

Documentation

License

MIT