OpenAPI to Composables
Generate typed Nuxt composables directly from your OpenAPI schema.
generate a typed OpenAPI client, Nuxt composables, optional server routes, and headless connectors under openapi/.

Install the package and configure the Nuxt module:
npm install nuxt-openapi-hyperfetch// 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.
The generated root is openapi/. It contains the OpenAPI client plus any enabled helper layers:
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 composablesuseAsyncData composablesWhen nuxtServer is enabled, server routes are generated outside openapi/, under server/routes/api by default.
With useAsyncData enabled, the generated composables are immediately usable from Nuxt:
<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.
Optional generators stay explicit:
nuxtServer writes route handlers to server/routes/api by defaultconnectors depends on useAsyncData and writes connector composables under openapi/composables/connectorsThose layers are additive. You can keep the generated OpenAPI client only, add composables, or add server routes and connectors on top.
Generated composables and connectors can read the public runtime base URL from Nuxt:
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-openapi-hyperfetch'],
runtimeConfig: {
public: {
apiBaseUrl: process.env.NUXT_PUBLIC_API_BASE_URL || 'https://api.example.com',
},
},
})A connector groups CRUD behavior for one resource in one composable when the connectors generator is enabled.
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 IDcreate: validated create formupdate: validated update formdel: staged delete with confirmationRead more: