# lit-q

> A simple async query/mutation library for Lit/LitElement inspired by react-query

Latest version **0.3.10** (published 2024-02-15) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install lit-q
pnpm add lit-q
yarn add lit-q
bun add lit-q
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.3.10 |
| Published | 2024-02-15 |
| First published | 2023-01-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.0.0 |
| Dependencies | 0 |
| Unpacked size | 17.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Maintainers | explodingcamera |
| Keywords | lit, lit-html, lit-element, query, fetch, promise, mutation, react-query |

## Links

- npm: https://www.npmjs.com/package/lit-q
- Repository: https://github.com/explodingcamera/esm
- Homepage: https://github.com/explodingcamera/esm/tree/main/packages/lit-q
- Issues: https://github.com/explodingcamera/esm/issues
- npm.io page: https://npm.io/package/lit-q

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 0.3.10 (latest) — 2024-02-15
- 0.3.9 — 2024-02-12
- 0.3.8 — 2023-12-02
- 0.3.7 — 2023-08-22
- 0.3.6 — 2023-07-04
- 0.3.5 — 2023-05-10
- 0.3.4 — 2023-03-30
- 0.3.3 — 2023-03-17
- 0.3.2 — 2023-02-14
- 0.3.1 — 2023-01-24
- 0.3.0 — 2023-01-22
- 0.2.0 — 2023-01-13
- 0.1.1 — 2023-01-04
- 0.1.0 — 2023-01-04
- 0.0.1 — 2023-01-04

## README

# Lit-q [![API Docs](https://img.shields.io/badge/API%20Docs-blue.svg)](https://paka.dev/npm/lit-q)

> A simple query and mutation library for lit-element

## Installation

```bash
$ npm i lit-q
# or
$ yarn add lit-q
# or
$ pnpm add lit-q
```

## Usage

<table>
<tr>
<td> TypeScript </td>
</tr>
<tr>
<td>

```ts
import { html, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
import { query } from "lit-q";

@customElement("my-element")
export class MyElement extends LitElement {
  myQuery = new Query(this, "my-query", () => fetch("https://example.com"));
  myMutation = new Mutation(this, "my-mutation", () =>
    fetch("https://example.com", { method: "POST" })
  );

  render() {
    return html`
    <h1>My Query</h1>
    <p>
      ${this.myQuery.isLoading
        ? "Loading..."
        : this.myQuery.isError
        ? "Error!"
        : JSON.stringify(this.myQuery.data)}
    </p>
    <h1>My Mutation</h1>
    <button @click=${this.myMutation.mutate}>Mutate</button>
    <p>
      ${this.myMutation.isLoading
        ? "Loading..."
        : this.myMutation.isError
        ? "Error!"
        : JSON.stringify(this.myMutation.data)}
    </p>
    `;
}
```

</td>
</tr>
</table>

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