Overview
import { utils } from "mates" is a one-level proxy into the window MatesUtils store that renderApp creates. utils.pathAtom is the real atom; methods like utils.navigateTo are bound. The proxy itself holds no per-request state — each access looks the store up.
After renderApp, utils works inside components and outside them (fetch handlers, timers). useUtils() still works and returns the same instance; prefer utils when you are not in a component outer function.
Do not import pathAtom, themeAtom, or lsStore as module globals. Nested: utils.router is the same RouterUtils instance behind pathAtom / navigateTo. Storage and theme pages cover those bags in depth.
vs custom scope
|
API
|
Lifetime
|
Prefer when
|
|---|---|---|
utils / useUtils()
| one per window | Router, fetch, storage, theme — created by renderApp. |
scope(MyClass)
| subtree | Feature UI state shared parent→descendants. |
Read chrome from utils
pathAtom, themeAtom, titleAtom, and lsStore are all on the same MatesUtils instance.
navigateTo outside a component
After renderApp, a module-level helper can call utils.navigateTo — pathAtom stays in sync.