Terminal
Terminal/Skill
Guides wiring Monospace into a plain Vite and Vue app through the rstore Vite plugin, generated schema, and store setup.
By Directus
Works with
npx skills add directus/rstore --skill rstore-vite-monospaceUse @rstore/vite-monospace to generate Monospace-backed rstore schema and plugin modules in a non-Nuxt Vite app.
Register the Vite plugin in vite.config.ts:
import { rstoreMonospace } from '@rstore/vite-monospace'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
rstoreMonospace({
url: 'https://your-monospace-instance.com',
project: 'your-project',
schemaApiKey: process.env.MONOSPACE_API_KEY,
scopeId: 'rstore-monospace',
}),
],
})
Then create the store from the generated virtual module:
import { createStore, RstorePlugin } from '@rstore/vue'
import { monospacePlugin, schema } from 'virtual:rstore-monospace'
const store = await createStore({
schema,
plugins: [monospacePlugin],
})
app.use(RstorePlugin, { store })
| Option | Purpose |
|---|---|
url | Monospace API URL used for remote schema loading and runtime client code |
project | Monospace project identifier |
schemaApiKey | Build-time key for remote schema loading (needs openApiSchema:read + dataModel:read) |
input | Local OpenAPI JSON path, resolved from the Vite root |
metadataInput | Local schema metadata snapshot JSON path, resolved from the Vite root |
runtimeApiKey | Runtime API key emitted into generated client code |
scopeId | rstore plugin scope id, defaulting to rstore-monospace |
primaryKeys | Explicit primary key overrides by collection name |
dts | Declaration output path, true/omitted for rstore-monospace.d.ts, or false to disable |
virtual:rstore-monospace re-exports schema, monospace, and monospacePlugin.virtual:rstore-monospace/schema exports the generated rstore schema.virtual:rstore-monospace/plugin exports the Monospace REST client and rstore plugin.Use input plus metadataInput when the schema is checked into the project or generated separately. The metadata snapshot holds the raw items of the Monospace system schema meta collections keyed by collection name:
rstoreMonospace({
input: './openapi.json',
metadataInput: './schema-metadata.json',
})
With only one local file, the other schema source is loaded remotely and url/project are required.
schemaApiKey build-time only; it must not appear in generated virtual modules.runtimeApiKey only when the key is safe to emit into runtime/client code.schema and monospacePlugin together in the same store.rstore-monospace for OpenAPI, REST, query, and mutation behavior.rstore-vue for component query/form/cache patterns.