# Persistent store

> Six builtins provide a persistent key-value store backed by the resolved Harn state root (default .harn/store.json ):

Website: https://harnlang.com/spec/language/25-persistent-store.html

This page documents Harn, which is pre-1.0. Language, standard library, and CLI APIs may change. If the intended version is unclear, clarify before using this page.

---

<!-- Generated from spec/chapters/*.md by scripts/sync_language_spec.harn -->

## Persistent store

Six builtins provide a persistent key-value store backed by the resolved Harn
state root (default `.harn/store.json`):

| Function | Description |
|---|---|
| `store_get(key)` | Retrieve value or nil |
| `store_set(key, value)` | Set key, auto-saves to disk |
| `store_delete(key)` | Remove key, auto-saves |
| `store_list()` | List all keys (sorted) |
| `store_save()` | Explicit flush to disk |
| `store_clear()` | Remove all keys, auto-saves |

The store file is created lazily on first mutation. In bridge mode, the
host can override these builtins via the bridge protocol. The state root can
be relocated with `HARN_STATE_DIR`.

---

## Read next

- [OAuth](https://harnlang.com/spec/language/24-oauth.md)
- [Checkpoint & resume](https://harnlang.com/spec/language/26-checkpoint-resume.md)
