This package originally comes from @victr/favicon-fetcher, but it doesn't exist anymore, so i just cloned it.
Favicon fetcher finds sites favicons and fetches them fast
npm i @victr/favicon-fetcher
import favicon from '@victr/favicon-fetcher'
window.onload = async function () {
const img = document.getElementById('some-id')
const url = await favicon.url('https://github.com')
img.src = url
}
export default {
url: (query: string) => Promise<string>,
img: (query: string) => Promise<Blob>,
}
Protocols need to be included in the :url
query. You can get your favicon as a plaintext url or a blob:
GET /text/:url
GET /blob/:url
# install
pnpm i -r
pnpm install
pnpm cloudflare:install
# debug
pnpm dev
pnpm cloudflare:dev