npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nuxt-openapi-hyperfetch

v2.0.4

Published

Nuxt module for generating an OpenAPI SDK, composables, server routes, and headless CRUD connectors.

Readme


Installation

Install the module in your Nuxt project.

npm install nuxt-openapi-hyperfetch

If you use connectors, also install zod:

npm install zod

Peer dependencies:

  • Nuxt 3 or 4
  • @nuxt/kit
  • zod when using connectors

What It Generates

The module uses an OpenAPI document as input and generates a layered output.

Base output under openapi/:

  • typed SDK functions
  • generated OpenAPI types
  • generated client files and barrel exports

Optional higher-level layers:

  • useFetch composables
  • useAsyncData composables
  • nuxtServer Nitro routes
  • headless CRUD connectors

Default generated root:

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

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

Quick Start

Register the module and point it to your OpenAPI file.

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

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

Then start Nuxt normally:

npm run dev

Generation runs during the Nuxt build lifecycle.

Current module defaults:

  • output: './openapi'
  • generators: ['useFetch', 'useAsyncData']
  • enableDevBuild: true
  • enableProductionBuild: true
  • enableAutoGeneration: false
  • enableAutoImport: true

Generated Composables

Generated names follow the OpenAPI operationId.

Example with useAsyncData:

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

<template>
  <div v-if="error">Request failed</div>
  <div v-else>{{ pet?.name }}</div>
</template>

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

Generators

Generators are additive. Choose the smallest set that matches your app.

| Generator | Output | Use it for | | --------- | ------ | ---------- | | useFetch | openapi/composables/use-fetch/ | straightforward component-level requests | | useAsyncData | openapi/composables/use-async-data/ | async flows, cache keys, raw variants, connector foundation | | nuxtServer | server/routes/api/ by default | server-owned API access and BFF patterns | | connectors | openapi/composables/connectors/ | headless CRUD helpers built on top of useAsyncData |

Examples:

openapi: {
  input: './swagger.yaml',
  generators: ['useFetch', 'useAsyncData'],
}
openapi: {
  input: './swagger.yaml',
  generators: ['useAsyncData', 'connectors'],
}
openapi: {
  input: './swagger.yaml',
  generators: ['nuxtServer'],
  serverRoutePath: 'server/routes/api',
  enableBff: true,
}

Connectors

When connectors is enabled, the module generates resource-oriented headless CRUD helpers on top of useAsyncData.

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

Connectors are useful when your app repeatedly builds list, detail, create, update, and delete flows around the same resource model.

Base URL Configuration

Generated composables and connectors can resolve their base URL from runtimeConfig.public.apiBaseUrl.

// nuxt.config.ts
export default defineNuxtConfig({
  runtimeConfig: {
    public: {
      apiBaseUrl: process.env.NUXT_PUBLIC_API_BASE_URL || 'https://api.example.com',
    },
  },
})

If you do not want a global fallback, you can still pass baseURL per call.

Global Headers and Callbacks

The generated runtime can integrate with two lightweight extension points:

  • useApiHeaders() or $getApiHeaders for shared request headers
  • getGlobalApiCallbacks for shared request lifecycle callbacks

This keeps auth and cross-cutting request behavior in your Nuxt app instead of hardcoding it into generated output.

Local Development

This repository includes a small development harness for contributor workflows:

npm run dev:generate:all
npm run dev:generate:openapi
npm run dev:generate:use-fetch
npm run dev:generate:use-async-data

These scripts are for repository development and smoke-testing generator changes.

Documentation

Contributing

npm install
npm run build
npm run validate

If your change affects generated output, also run the relevant dev:generate:* command and inspect openapi/.

See CONTRIBUTING.md.

License

Apache-2.0. See LICENSE.