vroqjs.com

03-app-structure/06-store-setup.md

Store setup

Store setup

Most Vroq apps use a centralized store created with createStore.

Store setup should be placed in a predictable location so ChatGPT and developers can quickly understand how state is configured.

Standard location

shared/store/configureStore.js
shared/store/initialState.js

configureStore.js responsibilities

configureStore.js should:

  • create the store using createStore
  • register feature reducers
  • register extensions
  • call feature action registration functions so MCP debugging tools can expose action schemas

Example pattern:

import { createStore } from "/vroqjs/system/store/createStore.js";
import { initialState } from "./initialState.js";
import { featureReducer } from "../../features/feature/index.js";

export function configureStore() {
  const store = createStore([
    featureReducer
  ], initialState);

  return store;
}

Rules

  • create the store only once in the application
  • register reducers by feature
  • keep store setup small and predictable
  • avoid placing feature logic directly in configureStore.js

Final rule

The store setup should make it easy to see which reducers and extensions the app uses.