Skip to content

Nuxt fix server client#3631

Open
rodriciru wants to merge 15 commits intohey-api:mainfrom
rodriciru:Nuxt-fix-server-client
Open

Nuxt fix server client#3631
rodriciru wants to merge 15 commits intohey-api:mainfrom
rodriciru:Nuxt-fix-server-client

Conversation

@rodriciru
Copy link

Summary
This PR introduces full support for isomorphic API clients within the Nuxt 3/4 ecosystem. Previously, the
@hey-api/client-nuxt was tightly coupled to Vue and could not be used inside Nitro server routes (/server/api/...).

This change enables the automatic generation and injection of a dedicated server-side client powered by
@hey-api/client-ofetch, allowing developers to use the same auto-imported SDK both in their .vue components and their
Nitro event handlers without any configuration overhead.

Fixes #1985 (#1985)

Key Changes

@hey-api/nuxt Module

  • Dual Client Generation: The module now generates two separate clients into .nuxt/heyapi/client and
    .nuxt/heyapi/server.
  • Nitro Integration: Automatically configures Nitro aliases so the same #hey-api import points to the Vue-friendly
    client on the frontend and the ofetch client on the server.
  • Transpilation Fix: Moved generated output from node_modules/.cache to the root .nuxt folder to bypass Rollup's
    restriction on transpiling TypeScript files inside the node_modules tree, fixing the "Expected ',' got 'ident'"
    error in Nitro.
  • Auto-imports: Registered auto-imports for the Nitro environment, enabling a seamless developer experience.

Ecosystem & Examples

  • Nuxt 4 Support: Bumped internal module dependencies to support Nuxt 4 and Vite 6.
  • Revamped Examples: Migrated the Nuxt example into a v3/v4 structure.
  • Isomorphic Demo: Added a new Nitro route example (/server/api/pet/[id].get.ts) that uses the auto-imported SDK
    directly on the server.
  • UI Improvements: Refined the demo dashboard with dynamic ID selection and comprehensive support for all Nuxt
    composables (useAsyncData, useFetch, etc.) while handling BigInt serialization correctly.

Testing

  1. Run pnpm dev in the examples/openapi-ts-nuxt/v4 directory.
  2. Verify that $fetch works in the browser.
  3. Click "call /api/pet/:id (Nitro)" to verify the server-side SDK is correctly fetching data through the Nitro
    client.
  4. Verify that all Nuxt reactive composables work without circular reference errors.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@changeset-bot
Copy link

changeset-bot bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: 5c7fca9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@example/openapi-ts-nuxt-v3 Minor
@example/openapi-ts-nuxt-v4 Minor
@hey-api/nuxt Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Mar 20, 2026

Someone is attempting to deploy a commit to the Hey API Team on Vercel.

A member of the Team first needs to authorize it.

@pullfrog
Copy link

pullfrog bot commented Mar 20, 2026

Error

agent completed without reporting progress

Pullfrog  | Rerun failed job ➔View workflow run | Triggered by Pullfrogpullfrog.com𝕏

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Mar 20, 2026
@rodriciru rodriciru force-pushed the Nuxt-fix-server-client branch from c39bc13 to 3e60e8c Compare March 23, 2026 11:05
@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.99%. Comparing base (bcdd174) to head (5c7fca9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3631   +/-   ##
=======================================
  Coverage   38.99%   38.99%           
=======================================
  Files         513      513           
  Lines       18771    18771           
  Branches     5565     5559    -6     
=======================================
  Hits         7319     7319           
  Misses       9255     9255           
  Partials     2197     2197           
Flag Coverage Δ
unittests 38.99% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 23, 2026

Open in StackBlitz

@hey-api/codegen-core

npm i https://pkg.pr.new/@hey-api/codegen-core@3631

@hey-api/json-schema-ref-parser

npm i https://pkg.pr.new/@hey-api/json-schema-ref-parser@3631

@hey-api/nuxt

npm i https://pkg.pr.new/@hey-api/nuxt@3631

@hey-api/openapi-ts

npm i https://pkg.pr.new/@hey-api/openapi-ts@3631

@hey-api/shared

npm i https://pkg.pr.new/@hey-api/shared@3631

@hey-api/types

npm i https://pkg.pr.new/@hey-api/types@3631

@hey-api/vite-plugin

npm i https://pkg.pr.new/@hey-api/vite-plugin@3631

commit: 5c7fca9

@rodriciru
Copy link
Author

Please, tell me if the double client is acceptable or not!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[nuxt-client] generated client cannot be used from within any server (non-vue-context) routes

1 participant