Render a reactive list
The recommended first success. Fetch contacts through one handler and render stable, keyed, ordered rows with useListInstance.
Render a reactive list, sync one object, and track loading and error state. You bring the data layer; the composables stay transport agnostic.
<script setup>
import { useListInstance } from "@arrai-innovations/reactive-helpers";
const contacts = useListInstance({
props: { pkKey: "contactId" },
handlers: {
list: async ({ pushObjects }) => {
const response = await fetch("/api/contacts");
pushObjects(await response.json());
},
},
});
contacts.list();
</script>
<template>
<ul>
<li v-for="row in contacts.state.objectsInOrder" :key="row.contactId">
{{ row.name }}
</li>
</ul>
</template>
The component above fetches contacts through one handler, keys each row by contactId, and renders them in push order. The composable owns the reactive state; your handler owns the request. Build a reactive list walks through it step by step, including loading and error state.