useFetch, useAsyncData, and SSR support out of the box.
Installation
Basic Usage
Configuration
The Nuxt client extends Nuxt’s fetch configuration:Client Options
Composables
The Nuxt client supports all Nuxt composables:$fetch
Direct fetch without reactivity:useFetch
Reactive data fetching with SSR support:useAsyncData
Custom async data handling:useLazyFetch
Lazy loading with useFetch:useLazyAsyncData
Lazy loading with useAsyncData:HTTP Methods
- GET
- POST
- PUT
- DELETE
Reactive Parameters
Use Vue refs for reactive query parameters:Authentication
Cookie-Based Authentication
Token from Composable
Per-Request Security
Server-Sent Events
Stream real-time data:Caching and Refresh
Manual Refresh
Auto Refresh
Cache Keys
SSR Support
Server-Side Rendering
Client-Only Fetching
Error Handling
Advanced Examples
Parallel Requests
Dependent Requests
Optimistic Updates
TypeScript Types
Best Practices
Use appropriate composables
Use appropriate composables
Choose the right composable for your use case:
$fetchfor one-off requestsuseFetchfor reactive SSR datauseAsyncDatafor custom async logicuseLazyFetchfor deferred loading
Leverage reactive parameters
Leverage reactive parameters
Use refs for parameters that should trigger re-fetching:
Set proper cache keys
Set proper cache keys
Use unique keys for caching:
Handle loading states
Handle loading states
Always show loading indicators:
Next Steps
Fetch Client
Learn about the underlying Fetch client
Composables
Explore Nuxt composables
SSR Support
Configure server-side rendering
Authentication
Set up API authentication