Prerequisites
Before installing Angular Query, ensure your project meets these requirements:- Angular 16+ - Angular Query uses signals and modern Angular features
- TypeScript 5.0+ - Required for full type inference
- Node.js 16+ - For package installation
Installation
Advanced Configuration
Using InjectionToken
For advanced use cases like lazy loading, you can provide theQueryClient using an InjectionToken:
query-client.ts
app.routes.ts
Using an
InjectionToken allows TanStack Query to be excluded from the main application bundle and only loaded with specific routes.Multiple QueryClient Instances
You can provide differentQueryClient instances for different parts of your application:
lazy-route.ts
Server-Side Rendering (SSR)
For Angular Universal applications, ensure theQueryClient is provided correctly:
app.config.server.ts
Verify Installation
Create a simple component to verify the installation:test.component.ts
Troubleshooting
Error: “No QueryClient found”
This error occurs whenprovideTanStackQuery is not in the provider tree. Ensure you’ve added it to your application config or module providers.
Error: “injectQuery must be called in an injection context”
Angular Query hooks must be called during component/service construction. See the injection context documentation for solutions.TypeScript Errors
Ensure you’re using TypeScript 5.0 or higher. Update yourtsconfig.json:
tsconfig.json
Next Steps
Quick Start
Build your first query
Queries Guide
Learn about queries in depth
DevTools
Set up debugging tools
API Reference
Explore the full API