Skip to main content
The Pinia Colada plugin generates fully typed query and mutation options for Vue applications using the Pinia Colada data fetching library. It provides a declarative, composable approach to managing server state in Vue.

Installation

1

Install Dependencies

Install Pinia Colada:
2

Configure Plugin

Add the plugin to your openapi-ts.config.ts:
3

Generate Client

Run the generator:

Generated Code

The plugin generates the following artifacts:

Query Options (GET operations)

For GET operations, query options wrapped in defineQueryOptions are generated:
packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts

Mutation Options (POST/PUT/DELETE operations)

For mutations, mutation options are generated:
packages/openapi-ts/src/plugins/@pinia/colada/mutationOptions.ts

Query Keys

Query key functions are generated for cache management:
Query keys can also be disabled if you prefer using the inline key generation:

Configuration

Query Options

Configure query options generation:

Mutation Options

Configure mutation options generation:

Query Keys

Configure query key generation:

Casing Convention

Set the casing convention for all generated names:

Usage Examples

Basic Query

examples/openapi-ts-pinia-colada/src/views/PiniaColadaExample.vue

Mutations

examples/openapi-ts-pinia-colada/src/views/PiniaColadaExample.vue

Conditional Queries

Enable or disable queries based on reactive conditions:

Query Invalidation

Invalidate queries using the query cache:
examples/openapi-ts-pinia-colada/src/views/PiniaColadaExample.vue

With Custom Headers

Pass custom headers or options:

Mutation with Optimistic Updates

Query Key Structure

Generated query keys follow this structure:
Example:

Advanced Patterns

Global Configuration

Apply configuration across all operations:

Disable Query Keys

If you don’t need separate query key exports:
examples/openapi-ts-pinia-colada/openapi-ts.config.ts

Custom Naming

Customize generated function names:

With Nuxt Client

The plugin automatically detects when using @hey-api/client-nuxt and adjusts type generation:

DevTools Integration

Pinia Colada includes devtools for debugging queries:

Type Safety

All generated queries and mutations are fully typed:

Pinia Colada Docs

Official Pinia Colada documentation

SDK Plugin

Learn about the SDK plugin used by Pinia Colada

Client Plugins

Configure HTTP clients (Fetch, Nuxt, etc.)

State Management Overview

Overview of all state management options