@crossbell/ipfs-fetch
v0.0.21
Published
<p align="left"> <a href="https://github.com/Crossbell-Box/crossbell-ipfs-utils/blob/main/LICENSE"> <img src="https://img.shields.io/npm/l/@crossbell/ipfs-fetch?colorA=373737&colorB=0A70E9&style=flat" alt="GitHub license" /> </a> <a href="https:
Downloads
1,628
Readme
@crossbell/ipfs-fetch
⚡ Fetch IPFS contents through the fastest gateway by sending requests to multiple gateways simultaneously. Try on CodeSandbox.
Installation
Using yarn:
yarn add @crossbell/ipfs-fetch
Or via npm:
npm install @crossbell/ipfs-fetch --save
Or via pnpm:
pnpm add @crossbell/ipfs-fetch
Examples
Basic fetch
import { ipfsFetch } from '@crossbell/ipfs-fetch'
ipfsFetch('ipfs://bafkreic5k3zvarbsondfrowy7kpbj6xo7cj25hobksgileqbbupjvvmkoq')
Custom gateways
import { ipfsFetch, IpfsGatewayTemplate } from '@crossbell/ipfs-fetch'
// Default gateways: https://github.com/Crossbell-Box/crossbell-ipfs-utils/blob/main/packages/ipfs-fetch/src/constant.ts
const gateways: IpfsGatewayTemplate[] = [
'https://{cid}.ipfs.cf-ipfs.com/{pathToResource}',
'https://ipfs.io/ipfs/{cid}{pathToResource}',
]
ipfsFetch('ipfs://bafkreic5k3zvarbsondfrowy7kpbj6xo7cj25hobksgileqbbupjvvmkoq', {
gateways,
})