Open History to see the last commit
1
2β
3[](https://www.npmjs.com/package/@tanstack/angular-query-experimental)
4[](https://github.com/TanStack/query/blob/main/LICENSE)
5[](https://bundlephobia.com/package/@tanstack/angular-query-experimental)
6[](https://www.npmjs.com/package/@tanstack/angular-query-experimental)
7β
8# Angular Query
9β
10> This library is currently in an experimental stage. This means that breaking changes will happen in minor AND patch releases. Use at your own risk. If you choose to rely on this in production in an experimental stage, please lock your version to a patch-level version to avoid unexpected breakages.
11β
12Functions for fetching, caching and updating asynchronous data in Angular
13β
14# Documentation
15β
16Visit https://tanstack.com/query/latest/docs/angular/overview
17β
18## Quick Features
19β
20- Transport/protocol/backend agnostic data fetching (REST, GraphQL, promises, whatever!)
21- Auto Caching + Refetching (stale-while-revalidate, Window Refocus, Polling/Realtime)
22- Parallel + Dependent Queries
23- Mutations + Reactive Query Refetching
24- Multi-layer Cache + Automatic Garbage Collection
25- Paginated + Cursor-based Queries
26- Load-More + Infinite Scroll Queries w/ Scroll Recovery
27- Request Cancellation
28- Dedicated Devtools
29β
30# Quick Start
31β
32> Angular Query requires Angular 17.
33β
341. Install `angular-query`
35β
36 ```bash
37 $ npm i @tanstack/angular-query-experimental
38 # or
39 $ pnpm add @tanstack/angular-query-experimental
40 # or
41 $ yarn add @tanstack/angular-query-experimental
42 ```
43β
442. Initialize **Angular Query** by adding **provideAngularQuery** to your application
45β
46 ```ts
47 import { provideAngularQuery } from '@tanstack/angular-query-experimental'
48 import { QueryClient } from '@tanstack/angular-query-experimental'
49β
50 bootstrapApplication(AppComponent, {
51 providers: [provideAngularQuery(new QueryClient())],
52 })
53 ```
54β
553. Inject query
56β
57 ```ts
58 import { injectQuery } from '@tanstack/angular-query-experimental'
59 import { Component } from '@angular/core'
60β
61 @Component({...})
62 export class TodosComponent {
63 info = injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodoList }))
64 }
65 ```
66β
674. If you need to update options on your query dynamically, make sure to pass them as signals
68β
69 ```ts
70 import { injectQuery } from '@tanstack/angular-query-experimental'
71 import { signal, Component } from '@angular/core'
72β
73 @Component({...})
74 export class TodosComponent {
75 id = signal(1)
76 enabled = signal(false)
77β
78 info = injectQuery(() => ({
79 queryKey: ['todos', this.id()],
80 queryFn: fetchTodoList,
81 enabled: this.enabled(),
82 }))
83 }
84 ```