# Setup and Configuration

## Installation

```
npm i @ngrx/{store,effects,entity,router-store}
```

```
ng add @ngrx/store-devtools
```

```
npm i @ngrx/{schematics,store-devtools} ngrx-store-freeze --save-dev
```

## Configuration Best Practices

* **Use module pattern**
  * **State Module**
  * **Core Module**
* **App Interfaces**
  * **Minimum app state**
* **App Reducer**
  * **Create AppReducerMap using AppState**
  * **Store Freeze**
* **State Module**
  * **Registers minimum effects**
  * **RouterStateSerializer**
  * **StoreDev Tools**

## Store Dev Tools and Store Freeze

{% code title="app.module.ts" %}

```typescript
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { ActionReducerMap, MetaReducer, StoreModule } from '@ngrx/store';
import { storeFreeze } from 'ngrx-store-freeze';

import { AppComponent } from './app.component';
import { HelloComponent } from './hello.component';

import { environment }  from '../environment/environment';
import { UserService } from './core/services/user.service';

export interface State {
  // states
}

export const storeDevTools = !environment.production ? StoreDevtoolsModule.instrument() : [];

export const metaReducers: MetaReducer<State>[] = !environment ? [storeFreeze] : [];

export const reducers: ActionReducerMap<State> = {
  // reducers
}

@NgModule({
  imports: [ 
    BrowserModule, 
    FormsModule, 
    StoreModule.forRoot(reducers, { metaReducers }),
    storeDevTools 
  ],
  declarations: [ AppComponent, HelloComponent ],
  bootstrap:    [ AppComponent ],
  providers: [UserService]
})
export class AppModule { }

```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://briebug.gitbook.io/ngrx-workshop/setup-and-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
