You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which scope/s are relevant/related to the feature request?
Don't know / other
Information
Hi,
I'm currently using AnalogJS for some of my projects, and I really appreciate its capabilities! Since the Nitro server already generates information about API routes, I was wondering if it would be possible to extend the HTTP client to provide type-safe requests, similar to how $fetch works in Nuxt.
To explore this idea, I created a small example where I wrapped HttpClient to support typed API routes automatically. This approach enhances developer experience by enabling autocomplete for API endpoints and strict type safety for responses.
This discussion was converted from issue #1636 on March 10, 2025 01:32.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Which scope/s are relevant/related to the feature request?
Don't know / other
Information
Hi,
I'm currently using AnalogJS for some of my projects, and I really appreciate its capabilities! Since the Nitro server already generates information about API routes, I was wondering if it would be possible to extend the HTTP client to provide type-safe requests, similar to how $fetch works in Nuxt.
To explore this idea, I created a small example where I wrapped HttpClient to support typed API routes automatically. This approach enhances developer experience by enabling autocomplete for API endpoints and strict type safety for responses.
To make this work, I need to include the generated Nitro route types using:
/// <reference path="../dist/.nitro/types/nitro.d.ts" />
With this setup, I can inject $HttpClient and get code completion for API routes as well as automatic type resolution based on the selected route.
Usage:
inject($HttpClient).get('/v1/example')
Would this be something worth integrating into AnalogJS?
Let me know what you think! 🚀
Describe any alternatives/workarounds you're currently using
No response
I would be willing to submit a PR to fix this issue
Beta Was this translation helpful? Give feedback.
All reactions