---
title: TypeScript quickstart
description: Add an item to a list and read the list back from a TypeScript program with the Luna client.
related:
  - /clients/call-lunas-from-typescript
  - /clients/use-luna-with-react
  - /quickstart
---

At the end of this page you have a TypeScript program that adds an item to a `List` luna and reads the list back. It uses `createClient` from `luna/client` and runs with Node.js.

## Prerequisites

- The [Quickstart](/quickstart) done, with `luna dev` running the `List` luna and its URL and key in `.env.local`.
- Node.js 22.18 or later.

1. **Install the SDK**

    ```bash
    npm install --install-links "$(luna sdk ts --path)"
    ```

2. **Use ES modules**

    ```bash
    npm pkg set type=module
    ```

3. **Write the program**

    Add an `app` folder beside the `luna` folder.

    - .env.local
    - package.json
    - app/
      - main.ts
    - luna/
      - luna.config.ts
      - lunas/
        - list.ts

    ```ts app/main.ts
    import { createClient } from "luna/client";
    import type { List } from "../luna/lunas/list.ts";

    const client = createClient({ url: process.env.LUNA_URL!, key: process.env.LUNA_KEY });
    const list = client.luna<typeof List>("List", "weekend");

    await list.mutate("add", { text: "bread" });
    const items = await list.read("all");
    for (const item of items) console.log(item.text);

    client.close();
    ```

4. **Run it**

    ```bash
    node --env-file=.env.local app/main.ts
    ```

## See the result

The program adds `bread` to the list named `weekend`, then prints each item of that list.

```text
bread
```

Run it again and the list holds two items. The type import of `List` checks each handler name and argument, and Node.js drops it when it runs the file.

## Next steps

- [Call lunas from TypeScript](/clients/call-lunas-from-typescript) covers every call, the client's options and its errors.
- [Use Luna with React](/clients/use-luna-with-react) shows the same list in a component that updates by itself.
- [Subscribe to a query](/realtime/subscribe-to-a-query) follows the list as other people change it.
