https://github.com/johannschopplich/nuxt-api-party
π¬ Securely connect to any API with a server proxy and generated composables
https://github.com/johannschopplich/nuxt-api-party
nuxt nuxt-auth nuxt-module nuxt-proxy
Last synced: 7 months ago
JSON representation
π¬ Securely connect to any API with a server proxy and generated composables
- Host: GitHub
- URL: https://github.com/johannschopplich/nuxt-api-party
- Owner: johannschopplich
- License: mit
- Created: 2022-10-07T15:01:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-22T09:50:38.000Z (about 1 year ago)
- Last Synced: 2025-05-15T04:56:58.493Z (about 1 year ago)
- Topics: nuxt, nuxt-auth, nuxt-module, nuxt-proxy
- Language: TypeScript
- Homepage: https://nuxt-api-party.byjohann.dev
- Size: 4 MB
- Stars: 280
- Watchers: 5
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[](https://nuxt-api-party.byjohann.dev)
# Nuxt API Party
[Nuxt](https://nuxt.com) module that provides seamless integration with multiple API endpoints. It generates **type-safe composables** for each API endpoint you configure, offering a familiar developer experience similar to Nuxt's `useFetch` and `$fetch` while keeping your **API credentials secure** and eliminating **CORS issues** through a server proxy.
- [β¨ Β Release Notes](https://github.com/johannschopplich/nuxt-api-party/releases)
- [π Β Read the documentation](https://nuxt-api-party.byjohann.dev)
## Features
- πͺ
[Auto-generated composables](https://nuxt-api-party.byjohann.dev/api/#generated-composables) for each API endpoint
- π Protected API credentials with Nuxt proxy route
- π No CORS issues
- π± Familiar developer experience to [`useFetch`](https://nuxt.com/docs/api/composables/use-fetch) and `$fetch`
- π§ [Connect all your APIs](https://nuxt-api-party.byjohann.dev/essentials/getting-started#configure-your-first-api-endpoint)
- π¦Ύ Fully typed API clients from [OpenAPI specifications](https://nuxt-api-party.byjohann.dev/guides/openapi-integration)
- π Smart caching & hydration
## Setup
> [!TIP]
> [π Read the documentation](https://nuxt-api-party.byjohann.dev)
```bash
npx nuxt module add api-party
```
## Basic Usage
> [!TIP]
> [π Read the documentation](https://nuxt-api-party.byjohann.dev)
Add the Nuxt API Party to your Nuxt config and prepare your first API connection by setting an endpoint object with the following properties for the `apiParty` module option:
```ts
// `nuxt.config.ts`
export default defineNuxtConfig({
modules: ['nuxt-api-party'],
apiParty: {
endpoints: {
jsonPlaceholder: {
url: process.env.JSON_PLACEHOLDER_API_BASE_URL!,
// Global headers sent with each request
headers: {
Authorization: `Bearer ${process.env.JSON_PLACEHOLDER_API_TOKEN}`
}
}
}
}
})
```
If you were to call your API `jsonPlaceholder`, the generated composables are:
- `$jsonPlaceholder` β Returns the response data, similar to [`$fetch`](https://nuxt.com/docs/api/utils/dollarfetch#fetch)
- `useJsonPlaceholderData` β Returns [multiple values](https://nuxt-api-party.byjohann.dev/api/use-fetch-like.html#return-values) similar to [`useFetch`](https://nuxt.com/docs/api/composables/use-fetch)
Use these composables in your templates or components:
```vue
const { data, refresh, error, status, clear } = await useJsonPlaceholderData('posts/1')
{{ data?.title }}
{{ JSON.stringify(data, undefined, 2) }}
```
> [!TIP]
> You can connect as many APIs as you want, just add them to the `endpoints` object.
## π» Development
1. Clone this repository
2. Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
3. Install dependencies using `pnpm install`
4. Run `pnpm run dev:prepare`
5. Start development server using `pnpm run dev`
## Special Thanks
- [Dennis Baum](https://github.com/dennisbaum) for sponsoring the initial version of this package.
- [Maronbeere](https://maronbeere.carrd.co) for his logo pixel art.
## License
[MIT](./LICENSE) License Β© 2022-PRESENT [Johann Schopplich](https://github.com/johannschopplich)
[MIT](./LICENSE) License Β© 2025-PRESENT [Matthew Messinger](https://github.com/mattmess1221)