---
title: Storage resources
description: "How KV, D1, R2 and queue stores get their stable ids, and the three ways to attach one."
---

KV namespaces, D1 databases, R2 buckets and queues are account-level resources with a stable id of the form `<kind>_<id>`. There are three ways to attach one.

## Bare name, let deploy provision it

```jsonc
"kv_namespaces": ["SESSIONS"]
```

On `deploy`, the CLI creates a resource named after the project and binding (`<project>-sessions`), writes `{ "binding": "SESSIONS", "id": "kv_..." }` back into `sproutboat.jsonc`, and uses it. This is the default. The store survives redeploys, and another project can bind the same id.

## Create it yourself, then reference the id

```sh npm
npx sproutboat kv create shared-sessions
# prints kv_a1b2c3d4...
```

```sh pnpm
pnpm sproutboat kv create shared-sessions
# prints kv_a1b2c3d4...
```

```sh bun
bunx sproutboat kv create shared-sessions
# prints kv_a1b2c3d4...
```

```sh yarn
yarn sproutboat kv create shared-sessions
# prints kv_a1b2c3d4...
```

```jsonc
"kv_namespaces": [{ "binding": "SESSIONS", "id": "kv_a1b2c3d4..." }]
```

Use the same id from two projects to share the store.

## `deploy --no-provision`

A bare name then gets a throwaway store for that one deployment, discarded on the next deploy. Use it for tests.

## Managing resources

```sh npm
npx sproutboat kv list
npx sproutboat d1 list
npx sproutboat r2 list
npx sproutboat queues list
```

```sh pnpm
pnpm sproutboat kv list
pnpm sproutboat d1 list
pnpm sproutboat r2 list
pnpm sproutboat queues list
```

```sh bun
bunx sproutboat kv list
bunx sproutboat d1 list
bunx sproutboat r2 list
bunx sproutboat queues list
```

```sh yarn
yarn sproutboat kv list
yarn sproutboat d1 list
yarn sproutboat r2 list
yarn sproutboat queues list
```

:::warning
A resource cannot be deleted while a deployment still binds it. Redeploy those projects without the binding first.
:::

[Analytics Engine](/docs/bindings/analytics-engine) datasets work differently: they take a bare name only and exist from their first `writeDataPoint`.

## Related

- [KV data management and export](/docs/storage/manage-kv-data)
- [CLI reference](/docs/reference/cli#storage): the `kv`, `d1`, `r2` and `queues` commands
