# @multiformats/dns

> Resolve DNS queries with browser fallback

Latest version **1.0.15** (published 2026-06-25) · Apache-2.0 OR MIT license · 0 weekly downloads

## Install

```sh
npm install @multiformats/dns
pnpm add @multiformats/dns
yarn add @multiformats/dns
bun add @multiformats/dns
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.15 |
| Published | 2026-06-25 |
| First published | 2024-03-08 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 6 |
| Unpacked size | 291.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Maintainers | daviddias, vmx, mikeal, hugomrdias, alanshaw, achingbrain, vascosantos, rvagg, lidel, npm-service-account-multiformats |

## Links

- npm: https://www.npmjs.com/package/@multiformats/dns
- Repository: https://github.com/multiformats/js-dns
- Homepage: https://github.com/multiformats/js-dns#readme
- Issues: https://github.com/multiformats/js-dns/issues
- npm.io page: https://npm.io/package/@multiformats/dns

## Dependencies (6)

- [hashlru](https://npm.io/package/hashlru.md) ^2.3.0
- [p-queue](https://npm.io/package/p-queue.md) ^9.0.0
- [uint8arrays](https://npm.io/package/uint8arrays.md) ^6.1.1
- [progress-events](https://npm.io/package/progress-events.md) ^1.0.0
- [@libp2p/interface](https://npm.io/package/@libp2p/interface.md) ^3.1.0
- [@dnsquery/dns-packet](https://npm.io/package/@dnsquery/dns-packet.md) ^6.1.1

## Recent versions

- 1.0.15 (latest) — 2026-06-25
- 1.0.14 — 2026-06-24
- 1.0.13 — 2026-01-20
- 1.0.12 — 2026-01-18
- 1.0.11 — 2025-12-07
- 1.0.10 — 2025-10-14
- 1.0.9 — 2025-09-08
- 1.0.8 — 2025-09-08
- 1.0.7 — 2025-09-08
- 1.0.6 — 2024-04-06
- 1.0.5 — 2024-03-14
- 1.0.4 — 2024-03-14
- 1.0.3 — 2024-03-13
- 1.0.2 — 2024-03-13
- 1.0.1 — 2024-03-08
- … 1 more at https://npm.io/package/@multiformats/dns/versions

## README

# @multiformats/dns

[![multiformats.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://multiformats.io)
[![codecov](https://img.shields.io/codecov/c/github/multiformats/js-dns.svg?style=flat-square)](https://codecov.io/gh/multiformats/js-dns)
[![CI](https://img.shields.io/github/actions/workflow/status/multiformats/js-dns/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/multiformats/js-dns/actions/workflows/js-test-and-release.yml?query=branch%3Amain)

> Resolve DNS queries with browser fallback

# About

<!--

!IMPORTANT!

Everything in this README between "# About" and "# Install" is automatically
generated and will be overwritten the next time the doc generator is run.

To make changes to this section, please update the @packageDocumentation section
of src/index.js or src/index.ts

To experiment with formatting, please run "npm run docs" from the root of this
repo and examine the changes made.

-->

Query DNS records using `node:dns`, DNS over HTTP and/or DNSJSON over HTTP.

A list of publicly accessible servers can be found [here](https://github.com/curl/curl/wiki/DNS-over-HTTPS#publicly-available-servers).

## Example - Using the default resolver

```TypeScript
import { dns } from '@multiformats/dns'

const resolver = dns()

// resolve A records with a 5s timeout
const result = await dns.query('google.com', {
  signal: AbortSignal.timeout(5000)
})
```

## Example - Using per-TLD resolvers

```TypeScript
import { dns } from '@multiformats/dns'
import { dnsJsonOverHttps } from '@multiformats/dns/resolvers'

const resolver = dns({
  resolvers: {
    // will only be used to resolve `.com` addresses
    'com.': dnsJsonOverHttps('https://cloudflare-dns.com/dns-query'),

    // this can also be an array, resolvers will be shuffled and tried in
    // series
    'net.': [
      dnsJsonOverHttps('https://dns.google/resolve'),
      dnsJsonOverHttps('https://dns.pub/dns-query')
    ],

    // will only be used to resolve all other addresses
    '.': dnsJsonOverHttps('https://dnsforge.de/dns-query'),
  }
})
```

## Example - Query for specific record types

```TypeScript
import { dns, RecordType } from '@multiformats/dns'

const resolver = dns()

// resolve only TXT records
const result = await dns.query('google.com', {
  types: [
    RecordType.TXT
  ]
})
```

## Caching

Individual Aanswers are cached so. If you make a request, for which all
record types are cached, all values will be pulled from the cache.

If any of the record types are not cached, a new request will be resolved as
if none of the records were cached, and the cache will be updated to include
the new results.

## Example - Ignoring the cache

```TypeScript
import { dns, RecordType } from '@multiformats/dns'

const resolver = dns()

// do not used cached results, always resolve a new query
const result = await dns.query('google.com', {
  cached: false
})
```

# Install

```console
$ npm i @multiformats/dns
```

## Browser `<script>` tag

Loading this module through a script tag will make its exports available as `MultiformatsDns` in the global namespace.

```html
<script src="https://unpkg.com/@multiformats/dns/dist/index.min.js"></script>
```

# API Docs

- <https://multiformats.github.io/js-dns>

# License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](https://github.com/multiformats/js-dns/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](https://github.com/multiformats/js-dns/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

# Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

---
_Source: https://npm.io/package/@multiformats/dns · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
