provideStoreApi sets up RTK Query to work with NgRx Store. It registers the API reducer with the store, initializes the hooks system, and optionally configures automatic refetching listeners.
Usage
Basic Setup
With Redux DevTools
Multiple APIs
Function Signature
Parameters
The RTK Query API instance created with
createApi. This defines your endpoints, base query, and cache behavior.Optional configuration object.
Returns
EnvironmentProviders - Angular environment providers that can be used in ApplicationConfig or route providers.
How It Works
- Store Integration: Registers the API’s reducer with NgRx Store under
api.reducerPath(defaults to'api') - Hook System: Creates Angular-compatible hooks (
useXxxQuery,useMutation, etc.) that use signals and store selectors - Listeners: Sets up automatic refetching on window focus and network reconnection (unless disabled)
- Dispatch Bridge: Connects RTK Query actions to NgRx Store’s dispatch mechanism
When to Use
UseprovideStoreApi when:
- Your application already uses NgRx Store
- You want Redux DevTools integration for debugging
- You need compatibility with other NgRx features (effects, router store, etc.)
- You want a single state management solution across your app
Prerequisites: You must call
provideStore() before provideStoreApi(). The NgRx Store must be available in the dependency injection tree.Common Errors
”Provide the Store is necessary”
provideStore() before provideStoreApi():
“Middleware not added”
If queries aren’t working, ensure the API reducer is registered:Comparison with provideNoopStoreApi
| Feature | provideStoreApi | provideNoopStoreApi |
|---|---|---|
| NgRx dependency | Required | None |
| Redux DevTools | Supported | Not available |
| State integration | Full NgRx Store | Standalone signal-based store |
| Bundle size | Larger (includes NgRx) | Smaller |
| Use case | Apps with NgRx | Standalone RTK Query |
See Also
- provideNoopStoreApi - Standalone store provider
- createApi - Create RTK Query API definitions
- Store Configuration Guide - Store setup and configuration