Registry / storage / hypercore-fetch

hypercore-fetch

JSON →
library10.2.0jsnpmunverified

A fetch() implementation for the Dat/Hypercore peer-to-peer ecosystem, enabling HTTP-style requests to p2p content via the hyper:// protocol. Current stable version 10.2.0 integrates with hyper-sdk to resolve keys, manage drives, and support GET, PUT, POST, DELETE operations. Supports DNSLink domains, directory listings, ETag-based versioning, and extension messages. Differentiates itself by bringing the familiar Fetch API to decentralized storage, with optional writability and lifecycle hooks for drive management. Release cadence is irregular; breaking changes may occur with hyper-sdk updates.

npm install hypercore-fetch
INSTALL
IMPORT
SIG · HYPERCORE-FETCH
H
hypercore-fetch
storagejavascriptv10.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

makeHyperFetch
import makeHyperFetch from 'hypercore-fetch'
const { makeHyperFetch } = require('hypercore-fetch')
Default export; named import pattern is incorrect for CommonJS. ESM-only since v10.
fetch
const fetch = await makeHyperFetch({ sdk })
const fetch = makeHyperFetch({ sdk })
makeHyperFetch is async and must be awaited (or .then'd) to obtain the fetch function.
Response
const response = await fetch(url)
const response = await makeHyperFetch(url)
makeHyperFetch is a factory, not a fetch replacement. Call the returned fetch function.

Shows creation of a hyper-sdk instance, initializing hypercore-fetch with write support, fetching content via GET, and uploading via PUT.

import makeHyperFetch from 'hypercore-fetch' import * as SDK from 'hyper-sdk' const sdk = await SDK.create({ storage: false }) const fetch = await makeHyperFetch({ sdk, writable: true }) // GET hyper:// protocol content const response = await fetch('hyper://blog.mauve.moe/') const text = await response.text() console.log(text) // PUT file to hyper://localhost/ const putResponse = await fetch('hyper://localhost/example.txt', { method: 'PUT', body: 'Hello World' }) const location = putResponse.headers.get('Location') console.log('Uploaded to:', location)
Debug
Known issues
breakingmakeHyperFetch is now async; must be awaited.
fix
await makeHyperFetch({...}) or use .then().
affects: >=10.0.0
breakingDefault export changed from named to default. Previously used require('hypercore-fetch').makeHyperFetch.
fix
Use import default or const make = (await import('hypercore-fetch')).default.
affects: >=10.0.0
breakingsdk option now expects a hyper-sdk instance, no longer a hypercore key or swarm.
fix
Create SDK via SDK.create() and pass to makeHyperFetch.
affects: >=10.0.0
deprecatedextensionMessages option defaults to writable; explicitly passing extensionMessages: true may be removed.
fix
Omit extensionMessages or set to writable value.
affects: >=10.0.0
gotchaMust consume response body (e.g., response.text()) after PUT to avoid memory leaks in Electron.
fix
Always await response.text() or response.arrayBuffer() after write operations.
affects: >=1.0.0
gotchahyper:// URLs require a valid key or domain; localhost only works for writable drives.
fix
Ensure drive is created or resolved via hyper-sdk before fetch.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: makeHyperFetch is not a function (or default is not a function)
Wrong import style; CommonJS require used instead of ESM default import or async import.
fix
Use import makeHyperFetch from 'hypercore-fetch' (ESM) or const make = await import('hypercore-fetch').then(m=>m.default).
TypeError: fetch is not a function
makeHyperFetch returned a promise that wasn't awaited; you're calling the factory instead of the fetch function.
fix
const fetch = await makeHyperFetch({...})
Error: SDK options must be provided
Missing or undefined sdk option in makeHyperFetch.
fix
Pass an SDK instance created with SDK.create() as { sdk }.
Upgrade
Version history
10.2.0latest on npm
Audit
Dependencies
hyper-sdkrequiredRequired for Hypercore drive creation and network replication
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
hypercore-fetch — npm install hypercore-fetch · libregistry