Directus logo

Skill

rstore-vue

manage application data with rstore in Vue

Covers Vue Frontend Debugging

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

Core concepts

PrimitivePurpose
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 / setActiveStoreInjects store into Vue or non-component/test contexts
store.<collection> and store.$collection(name)Entry point for read/write/query/form operations
query / liveQueryReactive queries with loading/error/meta/pagination semantics
realtimeReconnectEventHookShared reconnect signal used by realtime transports; liveQuery refreshes when it fires
useQueryTrackingTracks query membership and filters dirty cached items in reactive flows
createForm / updateForm / createFormObjectMutation 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 primitivesBacking implementation for collection/schema, find/peek/mutation/subscription behavior
@rstore/shared types + hooksCross-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

  1. Define collections and relations first.
  2. Create a store with createStore({ schema, plugins }).
  3. Install RstorePlugin in app code or set setActiveStore(store) in tests/non-injection contexts.
  4. Use collection APIs (find*, query, liveQuery) instead of custom fetch refs.
  5. Use createForm/updateForm for mutation UIs and createFormObject for custom flows.
  6. Move transport/data-source behavior into definePlugin hooks, not component-level code.
  7. 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

APIUse it for
peekFirst / peekManyCache-only reads for computed/reactive derivations
findFirst / findManyOne-shot async reads without long-lived query refs
queryReactive ref-based queries (data, loading, error, refresh)
liveQueryQuery + subscription lifecycle for realtime adapters
fetchMoreAdds page results to sparse pages and merged data
createForm / updateFormPreferred mutation UX; updateForm can prefetch item and send changed fields only
createFormObjectLower-level custom form builder with schema validation and hooks

Notes:

  • createFormObject supports validateOnSubmit, transformData, resetOnSuccess, $changedProps, and $valid.
  • Form objects expose $opLog for undo/redo and optimized form operations.
  • Use $rebase, $conflicts, and $resolveConflict for collaborative editing flows.
  • $save() and $onSaved() are deprecated compatibility aliases. Prefer $submit() and $onSuccess().

Modules and plugins

  • defineModule(name, cb) caches module instances in store.$modulesCache.
  • defineModule requires injection context or an explicit/active store.
  • definePlugin({ name, category, scopeId?, setup }) is the extension point for fetch/cache/mutation/subscription/sync hooks.
  • realtimeReconnectEventHook should be triggered by realtime plugins only after transport recovery; liveQuery refreshes 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

  1. Calling useStore() without installation/active store throws.
  2. defineModule outside setup without an available store throws.
  3. Query no-cache and cache-* behaviors differ materially; align changes with the documented query fetch-policy behavior.
  4. experimentalGarbageCollection affects query tracking behavior; use only with explicit coverage.
  5. Dynamic store.$collection(name) calls throw for unknown collection names.
  6. Avoid duplicating entity state outside store cache unless intentionally divergent.

References

TopicDescriptionReference
API indexFull map of all API-element referencesapi-index
withItemTypeTyped collection builder entry pointapi-with-item-type
defineCollectionUntyped collection declaration helperapi-define-collection
defineRelationsRelation declaration helperapi-define-relations
addCollectionRelationsAdd relation blocks after store creationapi-add-collection-relations
createStoreCreate store instance and lifecycleapi-create-store
addCollectionRegister a collection dynamicallyapi-add-collection
removeCollectionUnregister a collection dynamicallyapi-remove-collection
RstorePluginVue app plugin installationapi-rstore-plugin
useStoreInjected/active store accessapi-use-store
setActiveStoreExplicit active store bindingapi-set-active-store
definePluginStore plugin authoring APIapi-define-plugin
defineModuleStore-scoped module authoring APIapi-define-module
createFormObjectLow-level form object APIapi-create-form-object
createFormObjectWithChangeDetectionDeprecated alias for createFormObjectapi-create-form-object-with-change-detection
optimizeOpLogUtility to optimize form operation logsapi-optimize-op-log
useQueryTrackingQuery membership/dirty-item trackingapi-use-query-tracking
store.$wrapMutationWrap custom mutations in store mutation lifecycleapi-wrap-mutation
peekFirstCache-only first-item readapi-peek-first
findFirstAsync first-item readapi-find-first
peekManyCache-only list readapi-peek-many
findManyAsync list readapi-find-many
queryReactive query object APIapi-query
liveQueryQuery + subscription lifecycleapi-live-query
realtimeReconnectEventHookShared reconnect event hook for realtime transportsapi-realtime-reconnect-event-hook
subscribeSubscription API for updatesapi-subscribe
createSingle-item create mutationapi-create
createManyBatch create mutationapi-create-many
createFormCreate-form mutation helperapi-create-form
updateSingle-item update mutationapi-update
updateManyBatch update mutationapi-update-many
updateFormUpdate-form mutation helperapi-update-form
deleteSingle-item delete mutationapi-delete
deleteManyBatch delete mutationapi-delete-many
writeItemWrite/override item in cacheapi-write-item
clearItemRemove item from cache viewapi-clear-item

Further reading

© 2026 YourAI.tools. Every skill from an identity-verified publisher.

Independent catalog. Not affiliated with, endorsed by, or sponsored by Anthropic or any listed publisher. All trademarks belong to their respective owners.