# hamt-sharding

> JavaScript implementation of sharding using hash array mapped tries

Latest version **3.0.8** (published 2026-05-12) · Apache-2.0 OR MIT license · 0 weekly downloads

## Install

```sh
npm install hamt-sharding
pnpm add hamt-sharding
yarn add hamt-sharding
bun add hamt-sharding
```

## 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 | 3.0.8 |
| Published | 2026-05-12 |
| First published | 2018-11-21 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 2 |
| Unpacked size | 187.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 5 |
| Maintainers | achingbrain, npm-service-account-ipfs |
| Keywords | IPFS, hamt, sharding |

## Links

- npm: https://www.npmjs.com/package/hamt-sharding
- Repository: https://github.com/ipfs/js-hamt-sharding
- Homepage: https://github.com/ipfs/js-hamt-sharding#readme
- Issues: https://github.com/ipfs/js-hamt-sharding/issues
- npm.io page: https://npm.io/package/hamt-sharding

## Dependencies (2)

- [uint8arrays](https://npm.io/package/uint8arrays.md) ^6.1.1
- [sparse-array](https://npm.io/package/sparse-array.md) ^1.3.1

## Recent versions

- 3.0.8 (latest) — 2026-05-12
- 3.0.7 — 2026-05-12
- 3.0.6 — 2024-02-06
- 3.0.3 — 2024-02-06
- 3.0.2 — 2022-10-18
- 3.0.1 — 2022-08-11
- 3.0.0 — 2022-02-21
- 2.0.1 — 2021-08-23
- 2.0.0 — 2021-02-18
- 1.0.0 — 2020-01-08
- 0.0.2 — 2018-11-23
- 0.0.1 — 2018-11-21

## README

# hamt-sharding <!-- omit in toc -->

[![codecov](https://img.shields.io/codecov/c/github/ipfs-shipyard/js-hamt-sharding.svg?style=flat-square)](https://codecov.io/gh/ipfs-shipyard/js-hamt-sharding)
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs-shipyard/js-hamt-sharding/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/js-hamt-sharding/actions/workflows/js-test-and-release.yml?query=branch%3Amain)

> JavaScript implementation of sharding using hash array mapped tries

# 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.

-->

A [Hash Mapped Trie](https://en.wikipedia.org/wiki/Hash_array_mapped_trie) implementation for JavaScript.

This is used by [@helia/unixfs](https://www.npmjs.com/package/@helia/unixfs) for it's HAMT-sharded directory implementation.

## Example

```TypeScript
import { createHAMT } from 'hamt-sharding'
import crypto from 'crypto-promise'

// decide how to hash buffers made from keys, can return a Promise
const hashFn = async (buf) => {
  return crypto
    .createHash('sha256')
    .update(buf)
    .digest()
}

const bucket = createHAMT({
  hashFn: hashFn
})

await bucket.put('key', 'value')

const output = await bucket.get('key')
// output === 'value'
```

# Install

```console
$ npm i hamt-sharding
```

## Browser `<script>` tag

Loading this module through a script tag will make it's exports available as `HamtSharding` in the global namespace.

```html
<script src="https://unpkg.com/hamt-sharding/dist/index.min.js"></script>
```

# API Docs

- <https://ipfs-shipyard.github.io/js-hamt-sharding>

# License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](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/hamt-sharding · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
