Skip to content
Nuxt OpenAPI Hyperfetch
Main Navigation GuideComposablesServerConnectors

Appearance

Nuxt-only OpenAPI generation

generate a typed OpenAPI client, Nuxt composables, optional server routes, and headless connectors under openapi/.

Get started
View on GitHub
Nuxt OpenAPI Hyperfetch
OpenAPI logo

OpenAPI to Composables

Generate typed Nuxt composables directly from your OpenAPI schema.

⚙️

Nuxt module workflow

Generation is configured through nuxt.config.ts with the openapi module key. No product CLI is required.

🟢

Nuxt-native composables

Generate useFetch and useAsyncData composables on top of the OpenAPI client with Nuxt-friendly wrappers and auto-import support.

🧩

Headless UI connectors

When enabled, connectors are layered on top of generated useAsyncData composables for list, detail, create, update, and delete flows.

🔒

Server-first security with BFF

Generate Nuxt server routes outside openapi/ and keep secrets on the server with auth context and transformer stubs.

TypeScript icon

Typescript safe

Get typed params, responses, and composables generated from your schema.

Quick Start ​

Install the package and configure the Nuxt module:

bash
npm install nuxt-openapi-hyperfetch
ts
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-openapi-hyperfetch'],

  openapi: {
    input: './swagger.yaml',
    output: './openapi',
    generators: ['useAsyncData', 'connectors', 'nuxtServer'],
    enableAutoImport: true,
  },
})

Run your Nuxt app or build and the module generates the requested artifacts before the Nuxt build lifecycle continues.

What Gets Generated ​

The generated root is openapi/. It contains the OpenAPI client plus any enabled helper layers:

text
openapi/
  index.ts
  sdk.gen.ts
  types.gen.ts
  client.gen.ts
  client/
  core/
  composables/

Depending on your generators configuration, openapi/composables/ can contain:

  • useFetch composables
  • useAsyncData composables
  • Headless CRUD connectors

When nuxtServer is enabled, server routes are generated outside openapi/, under server/routes/api by default.

Generated Composables ​

With useAsyncData enabled, the generated composables are immediately usable from Nuxt:

vue
<script setup lang="ts">
const { data: pet, pending, error } = await useAsyncDataGetPetById({
  path: { petId: 123 },
})

const { data: rawPet, status, headers } = await useAsyncDataGetPetByIdRaw({
  path: { petId: 123 },
})

watchEffect(() => {
  console.log(pet.value?.name)
  console.log(rawPet.value)
  console.log(status.value)
  console.log(headers.value)
})
</script>

If you enable useFetch, the module also generates the parallel openapi/composables/use-fetch/ tree.

Server Routes and Connectors ​

Optional generators stay explicit:

  • nuxtServer writes route handlers to server/routes/api by default
  • connectors depends on useAsyncData and writes connector composables under openapi/composables/connectors

Those layers are additive. You can keep the generated OpenAPI client only, add composables, or add server routes and connectors on top.

Base URL Configuration ​

Generated composables and connectors can read the public runtime base URL from Nuxt:

ts
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-openapi-hyperfetch'],

  runtimeConfig: {
    public: {
      apiBaseUrl: process.env.NUXT_PUBLIC_API_BASE_URL || 'https://api.example.com',
    },
  },
})

Connectors ​

A connector groups CRUD behavior for one resource in one composable when the connectors generator is enabled.

ts
const { getAll, get, create, update, del } = usePetsConnector()

This gives you a clean base for tables, detail views, forms, and delete flows without wiring each operation manually.

  • getAll: list with SSR (useAsyncData)
  • get: load one item by ID
  • create: validated create form
  • update: validated update form
  • del: staged delete with confirmation

Read more:

  • Connectors Overview
  • OpenAPI Conventions for Connectors

What's Next? ​

  • New here? Start with the Getting Started Guide
  • Choosing a generator? Read useFetch vs useAsyncData vs Server Routes
  • Understanding how generation works? Read Core Concepts
  • Need the architecture view? Start at Architecture
  • Using connectors? Start at Connectors

Released under the Apache-2.0 License.

Copyright © 2026-present