Skip to main content
This guide walks you through installing and setting up Angular Query in your Angular application.

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 the QueryClient using an InjectionToken:
query-client.ts
Then use it in lazy loaded routes:
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 different QueryClient instances for different parts of your application:
lazy-route.ts

Server-Side Rendering (SSR)

For Angular Universal applications, ensure the QueryClient is provided correctly:
app.config.server.ts
For SSR, create a new QueryClient instance per request to avoid sharing state between users.

Verify Installation

Create a simple component to verify the installation:
test.component.ts
If you see “Angular Query is working!” after 1 second, your installation is complete!

Troubleshooting

Error: “No QueryClient found”

This error occurs when provideTanStackQuery 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 your tsconfig.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