# Behavior traces — pmndrs/jotai

> Canonical page: https://codevetter.com/unpack/jotai/behavior-traces

# Behavior traces — pmndrs/jotai

Scanned commit 6abd0ae3365e02ab432fba4b6e8e6f00aafbf508 (2026-09-29). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

The source walkthrough followed React startup and subscription, a concrete text-edit action, and storage initialization/write/reset end to end. Additional traces followed async Hacker News loading and website search/support behavior. The steps below describe execution order and relevant branches from source inspection. They are not runtime observations.
- Startup: the starter calls createRoot(...).render(<StrictMode><App/>); Counter calls useAtom(countAtom), useStore falls back to getDefaultStore, and createStore builds the store on first use. — [examples/starter/src/index.tsx#L9-L25](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/examples/starter/src/index.tsx#L9-L25) [examples/starter/src/index.tsx#L49-L53](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/examples/starter/src/index.tsx#L49-L53) [src/react/Provider.ts#L18-L20](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/react/Provider.ts#L18-L20) [src/vanilla/store.ts#L14-L25](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/vanilla/store.ts#L14-L25)
- Initial subscription: useAtomValueRaw initializes from store.get, then its effect invokes subscribe; store.sub mounts dependencies before the atom, adds the listener, recomputes, and flushes. createState then compares the rendered value against store.get and requests a rerender if changed or errored. — [src/react/useAtomValueRaw.ts#L19-L39](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/react/useAtomValueRaw.ts#L19-L39) [src/react/useAtomValueRaw.ts#L52-L75](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/react/useAtomValueRaw.ts#L52-L75) [src/vanilla/internals.ts#L992-L1039](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/vanilla/internals.ts#L992-L1039) [src/vanilla/internals.ts#L1142-L1157](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/vanilla/internals.ts#L1142-L1157)
- Text edit: Input.onChange sends e.target.value through useSetAtom to store.set; defaultWrite self-sets textAtom, writeAtomState invalidates dependents, and recomputation evaluates length/uppercase reads before subscribed components reread. — [examples/text_length/src/App.tsx#L3-L19](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/examples/text_length/src/App.tsx#L3-L19) [src/react/useSetAtom.ts#L30-L40](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/react/useSetAtom.ts#L30-L40) [src/vanilla/atom.ts#L127-L139](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/vanilla/atom.ts#L127-L139) [src/vanilla/internals.ts#L914-L926](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/vanilla/internals.ts#L914-L926)
- Cleanup: the raw hook's effect returns the store subscription cleanup; it removes the listener, unmounts atoms only when no listener or mounted dependent still requires them, then recomputes and flushes queued onUnmount callbacks. — [src/react/useAtomValueRaw.ts#L27-L38](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/react/useAtomValueRaw.ts#L27-L38) [src/react/useAtomValueRaw.ts#L75-L75](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/react/useAtomValueRaw.ts#L75-L75) [src/vanilla/internals.ts#L1055-L1080](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/vanilla/internals.ts#L1055-L1080) [src/vanilla/internals.ts#L1158-L1163](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/vanilla/internals.ts#L1158-L1163)
- Persistence: atomWithStorage constructs baseAtom from initialValue unless getOnInit requests storage; mounting reloads and subscribes. A normal write computes the next value, updates baseAtom, and calls setItem; a promise write waits for resolution; RESET restores initialValue and calls removeItem. — [src/vanilla/utils/atomWithStorage.ts#L222-L260](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/vanilla/utils/atomWithStorage.ts#L222-L260) [src/vanilla/utils/atomWithStorage.ts#L119-L144](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/vanilla/utils/atomWithStorage.ts#L119-L144)
- Async browsing: Next increments postId; postData reads that ID, fetches the Firebase item endpoint, and returns response.json(). PostTitle reads the promise through useAtomValue and renders under Suspense; replacement promises trigger abort handlers, although this example does not pass a signal to fetch. — [examples/hacker_news/src/App.tsx#L20-L55](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/examples/hacker_news/src/App.tsx#L20-L55) [examples/hacker_news/src/App.tsx#L60-L70](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/examples/hacker_news/src/App.tsx#L60-L70) [src/react/useAtomValue.ts#L66-L75](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/react/useAtomValue.ts#L66-L75) [src/vanilla/internals.ts#L1093-L1111](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/src/vanilla/internals.ts#L1093-L1111)
- Documentation search: SearchModal reads searchAtom, mounts InstantSearch on Docs, CustomSearchBox updates local query state and throttles refine by 200 ms, Boundary hides empty queries or reports zero hits, and Hit navigation closes the modal. — [website/src/components/search-modal.js#L23-L42](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/website/src/components/search-modal.js#L23-L42) [website/src/components/search-modal.js#L57-L98](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/website/src/components/search-modal.js#L57-L98) [website/src/components/search-modal.js#L125-L132](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/website/src/components/search-modal.js#L125-L132)
- Support inquiry: handleSubmit rejects a filled client honeypot or previously completed submission, marks the form submitted, and POSTs JSON to /api/contact; the handler rejects missing fields, awaits sendEmail, and returns 200 or 500. Only a 200 response sets hasReceived and clears fields. — [website/src/components/support.js#L13-L43](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/website/src/components/support.js#L13-L43) [website/api/contact.js#L5-L31](https://github.com/pmndrs/jotai/blob/6abd0ae3365e02ab432fba4b6e8e6f00aafbf508/website/api/contact.js#L5-L31)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
