Skip to main content

What is Akita?

Akita is a library for managing state in Angular, an alternative to NgRx and NGXS, with an emphasis on simplicity, structure, and an object-oriented approach.

The main idea:

Akita = reactive state + classes + less boilerplate code.

It helps you:

  • store data (in a store),
  • update it centrally (through methods),
  • subscribe to changes (through select()).

Main elements of Akita:

  1. Store
    • a class where the state lives
    • you set the initial state and manage it
  2. Query
    • a class for reading data from the store
    • convenient for getting selectName(), selectCount(), and so on
  3. Service
    • business logic: loading from an API, updates, deletions, and so on
    • calls store methods

Example:

ts
export interface Todo { id: number; title: string; } @StoreConfig({ name: 'todos' }) @Injectable() export class TodosStore extends Store<Todo[]> { constructor() { super([]); } }
ts
@Injectable() export class TodosQuery extends Query<Todo[]> { todos$ = this.select(); // subscribe to all todos constructor(protected store: TodosStore) { super(store); } }
ts
@Injectable() export class TodosService { constructor(private todosStore: TodosStore) {} add(todo: Todo) { this.todosStore.update(state => [...state, todo]); } }

How it differs from NgRx:

AkitaNgRx
ApproachClass-based, simpleFunctional, strict
ReducersNoneRequired
ActionsNot requiredRequired
RxJSUsed, but lightlyUsed heavily
Side effectsIn servicesThrough Effects

Conclusion:

Akita is a lightweight, easy-to-understand alternative to NgRx. If you want to manage state without unnecessary complexity, with good structure, Akita can be an ideal fit.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.