Implementation of the Fetch API that uses the Dat SDK for loading peer-to-peer content from hyper:// and dat:// URLs. Version 5.1.1 provides a browser-compatible fetch interface for reading and writing data in Dat archives. Release cadence is sporadic. It automatically resolves domain names via dat-dns, handles directory listings, and supports common HTTP methods. Requires the dat-sdk peer dependency. Suitable for building decentralized web applications.
npm install dat-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to import the factory, create a fetch instance, perform a GET request to a hyper:// URL, parse JSON response, and clean up.
Use hyper:// instead of dat://. If you must support dat://, pass a custom resolveName function that converts dat:// to hyper://.
Use default import: import makeFetch from 'dat-fetch'; const fetch = makeFetch();
Run npm install dat-sdk alongside dat-fetch.
Use Node.js 14 or higher.
Always call fetch.close() to be safe, but understand it may be a no-op in advanced usage.
Run 'npm install dat-sdk' in your project.
Use 'const fetch = require('dat-fetch')()' (CJS) or 'import makeFetch from 'dat-fetch'; const fetch = makeFetch();' (ESM).Check response.ok and response.headers.get('content-type') before calling .json().Ensure the URL starts with 'hyper://' or 'dat://'. For other protocols, use a different library.