# thin-backend-vue

> Vue support for thin

Latest version **0.10.1** (published 2022-07-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install thin-backend-vue
pnpm add thin-backend-vue
yarn add thin-backend-vue
bun add thin-backend-vue
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.10.1 |
| Published | 2022-07-30 |
| First published | 2022-05-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | digitally induced, Inc. |
| Maintainers | mpscholten |

## Links

- npm: https://www.npmjs.com/package/thin-backend-vue
- npm.io page: https://npm.io/package/thin-backend-vue

## Recent versions

- 0.10.1 (latest) — 2022-07-30
- 0.10.0 — 2022-07-13
- 0.9.0 — 2022-07-13
- 0.1.1 — 2022-05-15
- 0.1.0 — 2022-05-15

## README

# Thin + Vue

## Install

Inside your vue project:

```bash
npm install thin-backend thin-backend-vue
```

## Usage

1. Inside your `App.vue` add the following:

    ```vue
    <script setup lang="ts">
    // ...
    import { initThinBackend, ThinBackend } from 'thin-backend';

    initThinBackend({
        // Replace this with your project host:
        host: 'https://testus.thinbackend.app'
    });
    </script>

    <template>
        // Wrap your app with the <ThinBackend/> component
        <ThinBackend requireLogin>
            // ...
        </ThinBackend>
    </template>
    ```

2. Now you can use Thin functions like `useQuery` or `createRecord` from within your Vue app:

    ```vue
    <script setup lang="ts">
    import { createRecord, query, updateRecord, type Task } from 'thin-backend';
    import { useQuery } from 'thin-backend-vue';

    const tasks = useQuery(query('tasks').orderBy('createdAt'));

    function updateTask(task: Task) {
        updateRecord('tasks', task.id, { title: window.prompt('New title') || '' })
    }

    function addTask() {
        createRecord('tasks', {
            title: window.prompt('Title:') || ''
        });
    }
    </script>

    <template>
        <div v-for="task in tasks" v-on:dblclick="updateTask(task)">
            {{task.title}}
        </div>

        <button v-on:click="addTask()">Add Task</button>
    </template>
    ```

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