LogoTemplate0
Logo of Nuxt API Party on template0.com

Nuxt API Party

Nuxt module that generates type-safe composables for secure API access via a server proxy, with OpenAPI support.

Introduction

Nuxt API Party is a Nuxt module that auto-generates type-safe composables for every API endpoint you configure, proxying all requests through the Nuxt server to keep API credentials private and avoid CORS issues.

What is Nuxt API Party?

Nuxt API Party is an open-source Nuxt module, licensed under MIT and created by Johann Schopplich with ongoing maintenance by Matthew Messinger. It takes an endpoints object defined in your Nuxt configuration — each entry containing a url and optional headers — and generates two composables per endpoint: a $endpoint function that returns response data like $fetch, and a useEndpointData composable that returns data, refresh, error, status, and clear, similar to useFetch. The module runs inside Nuxt 3 projects and uses a Nitro server proxy route as the request bridge between the browser and the external API.

Key Features
  • Auto-generated composables — For each endpoint in apiParty.endpoints, Nuxt API Party creates a $endpoint function and a useEndpointData composable, matching the return shape of Nuxt's useFetch and $fetch.
  • Secure API credentials — Authorization headers and other secrets live only in nuxt.config.ts; the browser sends its requests to your Nuxt server, which forwards them, so tokens never appear in client-side code.
  • No CORS issues — Because the browser only interacts with your own origin, cross-origin restrictions on third-party APIs are bypassed automatically.
  • OpenAPI integration — The module can generate fully typed API clients from OpenAPI specifications, giving end-to-end TypeScript types for the external API's routes and payloads.
  • Smart caching and hydration — The generated composables support the same caching, revalidation, and hydration behavior as Nuxt's built-in useFetch.
  • Multiple endpoint support — You can add as many APIs as you want to the endpoints object; each one gets its own set of composables.
  • Familiar developer experience — Builders who already know useFetch and $fetch can use the generated composables without learning a new pattern.
  • Quick install — The module is installed with npx nuxt module add api-party, and the only setup is an apiParty block in nuxt.config.ts.
Who is it for?
  • Nuxt developers who need to call third-party REST APIs and want typed, reactive composables without writing hand-rolled fetch wrappers.
  • Developers building server-rendered or static Nuxt sites that aggregate data from multiple backends (e.g. a CMS and a payments provider) and want to keep API tokens on the server.
  • Teams consuming OpenAPI-defined APIs who would rather generate a typed client than manually maintain TypeScript interfaces.
  • Developers working on internal dashboards or admin tools where CORS restrictions from the external API would otherwise block browser requests.
Use cases
  • Multi-API frontends: configure a content API and a booking API under different endpoint names, then call useContentApiData and useBookingApiData in the relevant pages.
  • Server-side data fetching: use the generated composables inside Nuxt pages or components to fetch data during SSR, benefiting from useFetch-style caching and hydration.
  • OpenAPI-driven projects: point the module at an OpenAPI spec, get a fully typed client, and replace manually maintained API layers.
How does it work?

Installing with npx nuxt module add api-party adds the module to your project. In nuxt.config.ts, you declare an apiParty section with an endpoints object; each endpoint has a url (typically read from an environment variable) and optional headers. When you call the generated composable, the request goes to a Nitro server route that forwards it to the external API and returns the data, preserving credentials and avoiding cross-origin blocks.

FAQ
Is Nuxt API Party free?

Yes. It is released under the MIT License and available on GitHub (currently 305 stars). There is no paid tier or SaaS version; you install and run it inside your own Nuxt application.

Does Nuxt API Party support OpenAPI?

Yes. The module has a dedicated guide for OpenAPI integration and can generate fully typed API clients from an OpenAPI specification, so you get typed composables without defining interfaces by hand.

How are API keys kept out of the client?

The composables you call in components are front-end friendly, but the actual request is handled by a server proxy route defined by the module. Only the server knows the real headers you set in nuxt.config.ts; the browser never receives those tokens.

What composables are generated for an endpoint?

For an endpoint named jsonPlaceholder, Nuxt API Party generates $jsonPlaceholder, which returns the response data, and useJsonPlaceholderData, which returns data, refresh, error, status, and clear — the same shape as Nuxt's useFetch.

Can I connect more than one API?

Yes. The endpoints object accepts any number of entries. Each one results in its own pair of composables, so you can work with many APIs in the same Nuxt app without conflicts.

screenshot of Nuxt API Party on template0.com

Information

GitHub Info

  • Stars305
  • Last maintained2026/08/08
  • LicenseMIT
  • Primary languageTypeScript

Categories

Tags

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates