skills/bun-guides-http-fetch-unix/SKILL.md
fetch with unix domain sockets in Bun
npx skillsauth add jarle/bun-skills Bun fetch with unix domain sockets in BunInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
In Bun, the unix option in fetch() lets you send HTTP requests over a unix domain socket.
const unix = "/var/run/docker.sock";
const response = await fetch("http://localhost/info", { unix });
const body = await response.json();
console.log(body); // { ... }
The unix option is a string that specifies the local file path to a unix domain socket. The fetch() function will use the socket to send the request to the server instead of using a TCP network connection. https is also supported by using the https:// protocol in the URL instead of http://.
To send a POST request to an API endpoint over a unix domain socket:
const response = await fetch("https://hostname/a/path", {
unix: "/var/run/path/to/unix.sock",
method: "POST",
body: JSON.stringify({ message: "Hello from Bun!" }),
headers: {
"Content-Type": "application/json",
},
});
const body = await response.json();
development
Using TypeScript with Bun, including type definitions and compiler options
development
Learn how to write tests using Bun's Jest-compatible API with support for async tests, timeouts, and various test modifiers
testing
Learn how to use snapshot testing in Bun to save and compare output between test runs
testing
Learn about Bun test's runtime integration, environment variables, timeouts, and error handling