---
title: "Your First UniKVS"
description: "Store and read back values with UniKVS using in-memory storage."
---

In this tutorial, you will store and read back values using in-memory storage. It takes about 10 minutes. Set the internals aside and build something working first.

## Goal [#goal]

When you finish, you will be able to:

- Assemble a client with `Builder`.
- Initialize with `open()` and read/write with `set()` and `get()`.
- Clean up with `close()`.

## Prerequisites [#prerequisites]

- A working Node.js environment.
- A TypeScript project.

## Steps [#steps]

1. **Install packages**

    Install `unikvs` and `@unikvs/memory`.

    ```package-install
    npm install unikvs @unikvs/memory
    ```

2. **Assemble the client**

    Pass in-memory storage to `Builder` to create a client. Here the key `greeting` stores a string.

    ```ts
    import { Memory } from "@unikvs/memory";
    import * as unikvs from "unikvs";

    const kvs = new unikvs.Builder<{
      greeting: unikvs.PlainValue<string>;
    }>()
      .persist(new Memory())
      .build();
    ```

3. **Store and read back**

    Initialize with `open()`, then run `set()` and `get()`. Close with `close()` when done.

    ```ts
    await kvs.open();
    await kvs.set("greeting", "hello");

    const value = await kvs.get("greeting");
    console.log(value); // "hello"

    await kvs.close();
    ```

:::warning[Do not forget storage registration]
Call `persist()` at least once before `build()`. Calling `build()` with no registration throws `MissingStorageError`.
:::

## Review [#review]

The resulting setup looks like this:

```mermaid
flowchart LR
  A["App"] --> B["UniKVS client"]
  B --> C["Memory"]
```

- `persist()` registers a backend.
- `build()` creates the client.
- `open()` is required before reading and writing.

## Next Steps [#next-steps]

**[Installation](/unikvs/en/how-to/installation)**

Installation steps for your runtime.

**[Architecture](/unikvs/en/explanation/architecture)**

Understand the write and read flows.

**[Value Model](/unikvs/en/explanation/value-model)**

Single values vs. streams.

**[Storage Comparison](/unikvs/en/reference/comparison)**

Choose a backend beyond memory.
