# @solid-primitives/map

> The Map & WeakMap data structures as a reactive signals.

Latest version **0.7.4** (published 2026-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @solid-primitives/map
pnpm add @solid-primitives/map
yarn add @solid-primitives/map
bun add @solid-primitives/map
```

## Health

**Score 60/100 (C)** — status: active.

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

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.7.4 |
| Published | 2026-07-04 |
| First published | 2022-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 13.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Damian Tarnawski @thetarnav |
| Maintainers | davedbase, lexlohr, thetarnav. |
| Keywords | map, weakmap, solid, primitives |

## Links

- npm: https://www.npmjs.com/package/@solid-primitives/map
- Repository: https://github.com/solidjs-community/solid-primitives
- Homepage: https://primitives.solidjs.community/package/map
- Issues: https://github.com/solidjs-community/solid-primitives/issues
- npm.io page: https://npm.io/package/@solid-primitives/map

## Dependencies (1)

- [@solid-primitives/trigger](https://npm.io/package/@solid-primitives/trigger.md) ^1.2.4

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.7.4 (latest) — 2026-07-04
- 1.0.0-next.2 (next) — 2026-08-12
- 0.4.2-beta.0 (beta) — 2023-03-03
- 1.0.0-next.1 — 2026-07-18
- 1.0.0-next.0 — 2026-06-26
- 0.7.3 — 2026-02-24
- 0.7.2 — 2025-06-29
- 0.7.1 — 2025-04-27
- 0.7.0 — 2025-04-27
- 0.6.0 — 2025-01-22
- 0.5.0 — 2025-01-05
- 0.4.13 — 2024-09-29
- 0.4.12 — 2024-09-13
- 0.4.11 — 2024-03-05
- 0.4.10 — 2024-02-28
- … 19 more at https://npm.io/package/@solid-primitives/map/versions

## README

<p>
  <img width="100%" src="https://assets.solidjs.com/banner?type=Primitives&background=tiles&project=Map" alt="Solid Primitives Map">
</p>

# @solid-primitives/map

[![size](https://img.shields.io/bundlephobia/minzip/@solid-primitives/map?style=for-the-badge&label=size)](https://bundlephobia.com/package/@solid-primitives/map)
[![version](https://img.shields.io/npm/v/@solid-primitives/map?style=for-the-badge)](https://www.npmjs.com/package/@solid-primitives/map)
[![stage](https://img.shields.io/endpoint?style=for-the-badge&url=https%3A%2F%2Fraw.githubusercontent.com%2Fsolidjs-community%2Fsolid-primitives%2Fmain%2Fassets%2Fbadges%2Fstage-2.json)](https://github.com/solidjs-community/solid-primitives#contribution-process)

The reactive versions of `Map` & `WeakMap` built-in data structures.

- **[`ReactiveMap`](#reactivemap-and-reactiveweakmap)** - A reactive `Map`.
- **[`ReactiveWeakMap`](#reactivemap-and-reactiveweakmap)** - A reactive `WeakMap`.

## Installation

```bash
npm install @solid-primitives/map
# or
yarn add @solid-primitives/map
# or
pnpm add @solid-primitives/map
```

## `ReactiveMap` and `ReactiveWeakMap`

A reactive version of `Map`/`WeakMap` data structure. All the reads _(e.g. `get` or `has`)_ are signals, and all the writes _(e.g. `delete` or `set`)_ will cause updates to appropriate signals.

### How to use it

#### Import

```ts
import { ReactiveMap } from "@solid-primitives/map";
// or
import { ReactiveWeakMap } from "@solid-primitives/map";
```

#### Basic usage

The usage is almost the same as the original Javascript structures.

```ts
const userPoints = new ReactiveMap<User, number>();
// reads can be listened to reactively
createEffect(() => {
  userPoints.get(user1); // => T: number | undefined (reactive)
  userPoints.has(user1); // => T: boolean (reactive)
  // ReactiveWeakMap won't have .size or any methods that loop over the values
  userPoints.size; // => T: number (reactive)
});
// apply changes
userPoints.set(user1, 100);
userPoints.delete(user2);
userPoints.set(user1, { foo: "bar" });
```

#### Constructor arguments

`ReactiveMap`'s and `ReactiveWeakMap`'s constructor one optional argument that is the initial entries of the map.

```ts
const map = new ReactiveMap([
  ["foo", [1, 2, 3]],
  ["bar", [3, 4, 5]],
]);
```

#### Values are shallowly wrapped

Treat the values of `ReactiveMap` and `ReactiveMap` as individual signals, to cause updates, they have to be set through the `.set()` method, no mutations.

```ts
const map = new ReactiveMap<string, { age: number }>();
map.set("John", { age: 34 });

// this won't cause any updates:
map.get("John").age = 35;

// this will:
map.set("John", { age: 35 });
```

## Changelog

See [CHANGELOG.md](./CHANGELOG.md)

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