ipfs-base
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

ipfs-base

Browser utility lib to configure web3 apps for IPFS hosting

npm i ipfs-base -S

API


import { createBase, getBase } from 'ipfs-base'

createBase: (basePath?: string) => string | undefined

Returns the ipfs|ipns base path for the application if currently loaded via a gateway url and injects a <base href={base} /> element into the head of the DOM.

Optional basePath if your application is not deployed at the root of the domain. eg: /base/path

getBase: (basePath?: string) => string | undefined

Returns the current base path with IPFS & IPNS detection.

Optional basePath if your application is not deployed at the root of the domain. eg: /base/path

Example:

  • without IPFS: getBase() => undefined
  • with IPFS: getBase() => '/ipfs|ipns/{hash|domain}'

With a root basePath:

  • without IPFS: getBase('/base/path') => '/base/path
  • with IPFS: getBase('/base/path') => '/ipfs|ipns/{hash|domain}/base/path

Usage with Vue Router

import { createRouter, createWebHistory } from 'vue-router'
import { createBase } from 'ipfs-base'

const router = createRouter({
  history: createWebHistory(createBase()),
  routes
})

Usage with React Router

TODO:

Package Sidebar

Install

npm i ipfs-base

Weekly Downloads

14

Version

1.1.0

License

MIT

Unpacked Size

6.45 kB

Total Files

6

Last publish

Collaborators

  • cwaring