
Description
Use when handling app data in Vue with `@rstore/vue` — fetch items/lists, keep queries reactive or live, create/update/delete records with forms, manage cache consistency, and debug store/query/subscription behavior across collections; also use before writing a custom fetch composable, ad hoc fetch ref, or bespoke cache layer for collection data — prefer `find*`, `query`, `liveQuery`, `createForm`, and `definePlugin` hooks over hand-rolled fetching/caching.
SKILL.md
Rstore Vue
Build typed, cache-first Vue data flows with @rstore/vue, including core engine and shared contract behavior.
Documentation map
| Area | Documentation |
|---|---|
| Getting started | https://rstore.akryum.dev/guide/getting-started#vue |
| Collection schema | https://rstore.akryum.dev/guide/schema/collection |
| Relations | https://rstore.akryum.dev/guide/schema/relations |
| Query and live query | https://rstore.akryum.dev/guide/data/query, https://rstore.akryum.dev/guide/data/live |
| Mutations and forms | https://rstore.akryum.dev/guide/data/mutation, https://rstore.akryum.dev/guide/data/form |
| Cache and modules | https://rstore.akryum.dev/guide/data/cache, https://rstore.akryum.dev/guide/data/module |
| Plugin setup and hooks | https://rstore.akryum.dev/guide/plugin/setup, https://rstore.akryum.dev/guide/plugin/hooks |
| Skill-local API references | ./references/index.md |
Core concepts
| Primitive | Purpose |
|---|---|
withItemType(...).defineCollection(...) | Defines a typed collection contract before using it in components |
defineRelations(...) | Defines normalized cross-collection relations once |
addCollectionRelations(store, relations) | Adds relation blocks after store creation when schema is composed dynamically |
createStore({ schema, plugins, ... }) | Builds store core, cache, hook system, and per-collection API proxies |
RstorePlugin / setActiveStore | Injects store into Vue or non-component/test contexts |
store.<collection> and store.$collection(name) | Entry point for read/write/query/form operations |
query / liveQuery | Reactive queries with loading/error/meta/pagination semantics |
realtimeReconnectEventHook | Shared reconnect signal used by realtime transports; liveQuery refreshes when it fires |
useQueryTracking | Tracks query membership and filters dirty cached items in reactive flows |
createForm / updateForm / createFormObject | Mutation and validation workflow with submit/reset/change tracking |
definePlugin({ ... }) | Extends fetch/cache/mutation/subscribe/sync behavior via hooks |
defineModule(name, cb) | Creates store-scoped reusable logic with per-store caching |
@rstore/core primitives | Backing implementation for collection/schema, find/peek/mutation/subscription behavior |
@rstore/shared types + hooks | Cross-package contracts for options, meta, payloads, and utilities |
Quick start
import { createStore, RstorePlugin, withItemType } from '@rstore/vue'
export const todos = withItemType<Todo>().defineCollection({
name: 'todos',
})
const store = await createStore({
schema: [todos],
plugins: [],
})
app.use(RstorePlugin, { store })
Task workflow
- Define collections and relations first.
- Create a store with
createStore({ schema, plugins }). - Install
RstorePluginin app code or setsetActiveStore(store)in tests/non-injection contexts. - Use collection APIs (
find*,query,liveQuery) instead of custom fetch refs. - Use
createForm/updateFormfor mutation UIs andcreateFormObjectfor custom flows. - Move transport/data-source behavior into
definePluginhooks, not component-level code. - When behavior is unclear, check docs and skill references first; if docs are incomplete or wrong, fix docs before updating this skill.
Query and form guidance
| API | Use it for |
|---|---|
peekFirst / peekMany | Cache-only reads for computed/reactive derivations |
findFirst / findMany | One-shot async reads without long-lived query refs |
query | Reactive ref-based queries (data, loading, error, refresh) |
liveQuery | Query + subscription lifecycle for realtime adapters |
fetchMore | Adds page results to sparse pages and merged data |
createForm / updateForm | Preferred mutation UX; updateForm can prefetch item and send changed fields only |
createFormObject | Lower-level custom form builder with schema validation and hooks |
Notes:
createFormObjectsupportsvalidateOnSubmit,transformData,resetOnSuccess,$changedProps, and$valid.- Form objects expose
$opLogfor undo/redo and optimized form operations. - Use
$rebase,$conflicts, and$resolveConflictfor collaborative editing flows. $save()and$onSaved()are deprecated compatibility aliases. Prefer$submit()and$onSuccess().
Modules and plugins
defineModule(name, cb)caches module instances instore.$modulesCache.defineModulerequires injection context or an explicit/active store.definePlugin({ name, category, scopeId?, setup })is the extension point for fetch/cache/mutation/subscription/sync hooks.realtimeReconnectEventHookshould be triggered by realtime plugins only after transport recovery;liveQueryrefreshes automatically when it fires.addCollectionDefaults(...)is the right place for shared field parsing/default behavior.- Keep plugin behavior keyed by store/scope instead of global mutable state.
Guardrails
- Calling
useStore()without installation/active store throws. defineModuleoutside setup without an available store throws.- Query
no-cacheandcache-*behaviors differ materially; align changes with the documented query fetch-policy behavior. experimentalGarbageCollectionaffects query tracking behavior; use only with explicit coverage.- Dynamic
store.$collection(name)calls throw for unknown collection names. - Avoid duplicating entity state outside store cache unless intentionally divergent.
References
| Topic | Description | Reference |
|---|---|---|
| API index | Full map of all API-element references | api-index |
| withItemType | Typed collection builder entry point | api-with-item-type |
| defineCollection | Untyped collection declaration helper | api-define-collection |
| defineRelations | Relation declaration helper | api-define-relations |
| addCollectionRelations | Add relation blocks after store creation | api-add-collection-relations |
| createStore | Create store instance and lifecycle | api-create-store |
| addCollection | Register a collection dynamically | api-add-collection |
| removeCollection | Unregister a collection dynamically | api-remove-collection |
| RstorePlugin | Vue app plugin installation | api-rstore-plugin |
| useStore | Injected/active store access | api-use-store |
| setActiveStore | Explicit active store binding | api-set-active-store |
| definePlugin | Store plugin authoring API | api-define-plugin |
| defineModule | Store-scoped module authoring API | api-define-module |
| createFormObject | Low-level form object API | api-create-form-object |
| createFormObjectWithChangeDetection | Deprecated alias for createFormObject | api-create-form-object-with-change-detection |
| optimizeOpLog | Utility to optimize form operation logs | api-optimize-op-log |
| useQueryTracking | Query membership/dirty-item tracking | api-use-query-tracking |
| store.$wrapMutation | Wrap custom mutations in store mutation lifecycle | api-wrap-mutation |
| peekFirst | Cache-only first-item read | api-peek-first |
| findFirst | Async first-item read | api-find-first |
| peekMany | Cache-only list read | api-peek-many |
| findMany | Async list read | api-find-many |
| query | Reactive query object API | api-query |
| liveQuery | Query + subscription lifecycle | api-live-query |
| realtimeReconnectEventHook | Shared reconnect event hook for realtime transports | api-realtime-reconnect-event-hook |
| subscribe | Subscription API for updates | api-subscribe |
| create | Single-item create mutation | api-create |
| createMany | Batch create mutation | api-create-many |
| createForm | Create-form mutation helper | api-create-form |
| update | Single-item update mutation | api-update |
| updateMany | Batch update mutation | api-update-many |
| updateForm | Update-form mutation helper | api-update-form |
| delete | Single-item delete mutation | api-delete |
| deleteMany | Batch delete mutation | api-delete-many |
| writeItem | Write/override item in cache | api-write-item |
| clearItem | Remove item from cache view | api-clear-item |
Further reading
- Guide index: https://rstore.akryum.dev/guide/learn-more
- Query docs: https://rstore.akryum.dev/guide/data/query
- Mutation docs: https://rstore.akryum.dev/guide/data/mutation
- Form docs: https://rstore.akryum.dev/guide/data/form
- Plugin hook docs: https://rstore.akryum.dev/guide/plugin/hooks
More skills from the rstore repository
View all 8 skillsrstore-directus
integrate rstore with Directus
Jul 12API DevelopmentDatabaseDirectusrstore-monospace
integrate rstore with Monospace REST APIs
Jul 12OpenAPIREST APIrstore-nuxt
integrate rstore into Nuxt applications
Jul 12FrontendNuxtVuerstore-nuxt-drizzle
expose Drizzle data in Nuxt applications
Jul 12API DevelopmentDatabaseDrizzleNuxtrstore-nuxt-monospace
integrate Monospace into Nuxt applications
Jul 12API DevelopmentDirectusNuxtVuerstore-vite-directus
integrate Directus into Vite applications
Jul 12API DevelopmentDirectusViteVue