# rstore-nuxt-monospace

Guides wiring Monospace into a Nuxt app through the rstore Nuxt module, generated collections, runtime API keys, and primary keys.

Skill by Directus. Category: Web and browsers.

## Install

Project (for this project only):

```sh
npx skills add directus/rstore --skill rstore-nuxt-monospace
```

Works with: Claude Code, Codex CLI, Cursor, Antigravity, Copilot CLI, opencode.

Global (for every project on this machine):

```sh
npx skills add directus/rstore --skill rstore-nuxt-monospace -g
```

Works with: Claude Code, Codex CLI, Cursor, Antigravity, Copilot CLI, opencode.

## Tags

- Runs on your computer: It runs as a program on your machine, with your access.

## Security audits

- Gen Agent Trust Hub: Pass
- Socket: Pass
- Snyk: Pass

Installs: 2. Installs counted by skills.sh. [Open on skills.sh](https://www.skills.sh/directus/rstore/rstore-nuxt-monospace)

## Source

[Open the source](https://github.com/directus/rstore/tree/HEAD/packages/nuxt-monospace/skills/rstore-nuxt-monospace). Checked 2026-10-10. This summary may contain AI-generated text, so it can be wrong. Check the source before you rely on it.

## SKILL.md

````markdown
---
name: rstore-nuxt-monospace
description: "Use when wiring Monospace into a Nuxt app with @rstore/nuxt-monospace, including rstoreMonospace config, remote or local OpenAPI generation, generated #build templates, runtime plugin setup, auto-imported useMonospace, runtimeApiKey handling, primaryKeys, and generated rstore collections. Pair with rstore-monospace for shared REST/OpenAPI behavior, rstore-nuxt for Nuxt store integration, and rstore-vue for query/form usage."
---

# Rstore Nuxt Monospace

Use `@rstore/nuxt-monospace` to generate Monospace-backed rstore collections and register the runtime REST plugin in Nuxt.

## Setup

Register the Nuxt module:

```ts
export default defineNuxtConfig({
  modules: [
    '@rstore/nuxt-monospace',
  ],
  rstoreMonospace: {
    url: 'https://your-monospace-instance.com',
    project: 'your-project',
    schemaApiKey: process.env.MONOSPACE_API_KEY,
    scopeId: 'rstore-monospace',
  },
})
```

Use generated collections through `useStore()`:

```ts
const store = useStore()

const { data } = await store.Todos.query(q => q.many({
  fields: ['id', 'title'],
  limit: 20,
}))
```

Use the auto-imported REST client when direct Monospace access is intentional:

```ts
const monospace = useMonospace()
const todos = await monospace.readMany('Todos', { limit: 10 })
```

## Options

| Option | Purpose |
| --- | --- |
| `url` | Monospace API URL |
| `project` | Monospace project identifier |
| `schemaApiKey` | Build-time key for remote schema loading (needs `openApiSchema:read` + `dataModel:read`) |
| `input` | Local OpenAPI JSON path, resolved from Nuxt root |
| `metadataInput` | Local schema metadata snapshot JSON path, resolved from Nuxt root |
| `runtimeApiKey` | Runtime API key emitted into generated config |
| `scopeId` | rstore plugin scope id, defaulting to `rstore-monospace` |
| `primaryKeys` | Explicit primary key overrides by collection name |

## Generated Nuxt Templates

- `$rstore-monospace-collections.js` contains runtime collection definitions.
- `$rstore-monospace-items.d.ts` contains generated item interfaces.
- `$rstore-monospace-collections.d.ts` contains typed collection declarations.
- `$rstore-monospace-config.js` contains runtime URL, project, optional API key, and scope id.

## Module Behavior

- The module depends on `@rstore/nuxt`.
- It adds generated collections through `addCollectionImport`.
- It adds the runtime plugin through `addPluginImport`.
- It registers runtime type references and auto-imports `useMonospace()`.
- Missing `url` or `project` skips collection generation with a warning.

## Guardrails

1. Keep `schemaApiKey` server-side/build-time.
2. Configure `runtimeApiKey` only when the value is safe to expose through generated runtime config.
3. Use `input` plus `metadataInput` for checked-in or separately generated schemas; generation needs both the OpenAPI document and the schema metadata.
4. Prefer generated rstore collections and plugin wiring over custom Nuxt API routes for generated collections.
5. Use `rstore-monospace` for shared OpenAPI, REST, query, and mutation behavior.
6. Use `rstore-nuxt` for base Nuxt rstore module behavior and `rstore-vue` for query/form/cache semantics.
````

- Previous: [rstore-nuxt](https://syn4pse.dev/terminal/rstore-nuxt.md)
- Next: [rstore-vite-directus](https://syn4pse.dev/terminal/rstore-vite-directus.md)
- [Terminal](https://syn4pse.dev/terminal.md)
- [Suggest a change](mailto:terminal@syn4pse.dev?subject=Terminal%20suggestion)
