Skip to content

Unofficial port of @instantdb/react for vue

License

ISC, Apache-2.0 licenses found

Licenses found

ISC
LICENSE
Apache-2.0
instantdb-license.md
Notifications You must be signed in to change notification settings

Dorilama/instantdb-vue

Repository files navigation

instantdb-vue

Unofficial port of @instantdb/react for vue

// ༼ つ ◕_◕ ༽つ Real-time Chat
// ----------------------------------
// * Updates instantly
// * Multiplayer
// * Works offline
<script setup>
import { init, tx, id } from "@dorilama/instantdb-vue";
import { Cursors } from "@dorilama/instantdb-vue/components";

const db = init({ appId: "my-app-id" });
// 1. Read
const { isLoading, error, data } = db.useQuery({
  messages: {},
});
const room = db.room("chat", "main");

// 2. Write
const addMessage = (message) => {
  db.transact(tx.messages[id()].update(message));
};
</script>
<template>
  <!-- 3. Render! -->
  <Cursors :room="room">
    <UI :data="data" @add="addMessage" />
  </Cursors>
</template>

The aim of this library is to have @instantdb/react for vue with feature parity. You should be able to follow the react docs and examples using this library. Arguments are reactive so you can use refs or getters. Cursors component has a separate import from @dorilama/instantdb-vue/components. Some of the functions return also a stop function to manually clear all side-effects and break live updated.


Related: this library tries to bring the same sdk for multiple signal based reactivity.

About

Unofficial port of @instantdb/react for vue

Topics

Resources

License

ISC, Apache-2.0 licenses found

Licenses found

ISC
LICENSE
Apache-2.0
instantdb-license.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published