What is Angular Query?
Angular Query is the Angular adapter for TanStack Query. It brings powerful and flexible server state management to Angular applications through a signal-based API that integrates seamlessly with Angular’s reactivity system.Key Features
Signal-Based Reactivity
Built on Angular signals for automatic reactivity and change detection
Automatic Caching
Smart caching with automatic refetching, deduplication, and garbage collection
Type Safety
Full TypeScript support with type inference from query functions
Developer Tools
Built-in devtools for debugging and monitoring queries
Core Concepts
Queries
Queries are declarative dependencies on asynchronous data sources. They automatically manage loading states, errors, and data updates:Mutations
Mutations are used for creating, updating, or deleting data:Signal Reactivity
Angular Query leverages Angular’s signals for automatic reactivity. The function passed toinjectQuery runs in a reactive context, similar to Angular’s computed:
filter signal changes, the query automatically updates with the new key and refetches data.
Requirements
Angular Query requires:- Angular 16 or higher - Uses modern Angular features including signals
- TypeScript 5.0+ - Full type inference and type safety
- @tanstack/query-core - Core query functionality (installed automatically)
Why Angular Query?
Before Angular Query
With Angular Query
- Loading and error states automatically
- Automatic cleanup on component destroy
- Smart caching and refetching
- Request deduplication
- Background updates
- Automatic garbage collection
Injection Context
All Angular Query hooks must be called within an injection context:Next Steps
Installation
Install and configure Angular Query in your project
Quick Start
Build your first query in minutes
DevTools
Debug and monitor your queries visually
Guides
Deep dive into queries, mutations, and more