hassanzohdy/atom/stores

Claude Code and agent skill by hassanzohdy/atom

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

How to use `AtomStore` and `createAtomStore` to isolate per-request atom state in SSR environments and avoid cross-request state leaks.

Install

npx vskill@latest install hassanzohdy/atom/stores

SKILL.md

Atom Stores (SSR)

The module-level atoms registry is shared per Node process. In an SSR context, two concurrent requests would write to the same atoms and see each other's state. AtomStore solves this by giving each request its own bag of scoped atom clones.

Why

ts
// app/users/page.tsx (Next.js server component)
const userAtom = createAtom({ key: "auth.user", default: { name: "Anon" } });
// During Request A
userAtom.update({ name: "Alice" });
// During Request B (concurrent), reading userAtom.value sees "Alice".
// That's a cross-request leak — the bug that AtomStore exists to fix.

Usage

ts
import { AtomStore, createAtomStore } from "@mongez/atom";
const store = createAtomStore(); // or new AtomStore()
// Lazily clones the original atom on first access.
const scopedUser = store.use(userAtom);
scopedUser.update({ name: "Alice" }); // only this store sees it
userAtom.value; // still { name: "Anon" }

API

ts
class AtomStore {
use<V, A>(template: Atom<V, A>): Atom<V, A>;
get<V>(key: string): Atom<V> | undefined;
has(key: string): boolean;
list(): Atom<any>[];
hydrate(snapshot: Record<string, unknown>): void;
snapshot(): Record<string, unknown>;
destroy(): void;
}
  • use(template) → returns the scoped clone, creating it lazily from the template's default value. Idempotent for atoms that are already scoped clones.
  • serverSnapshot(scoped) → the frozen first-pass value for React's getServerSnapshot.
  • hydrate(snapshot) → seeds values for atoms that may not have been accessed yet. Pending values are applied when the atom first enters the store.
  • snapshot() → serializable record of every scoped atom's current value.
  • destroy() → unsubscribes events for every scoped atom and clears the store. Always call at the end of a request lifecycle.

React integration

The hook-side wiring lives in `@mongez/react-atom`: <AtomStoreProvider>, useAtom(template | key), useAtomStore(). See its skills/stores.md.

Server-side hand-off pattern

ts
// Server (Express, Fastify, or any framework middleware)
import { createAtomStore } from "@mongez/atom";
app.get("/users", async (req, res) => {
const store = createAtomStore();
store.hydrate({ "auth.user": req.user }); // pre-seed from cookies/headers
try {
// Render with `store` made available via React context.
const html = renderToString(<AppShell store={store} />);
const payload = JSON.stringify(store.snapshot());
res.send(/* HTML + embedded payload */);
} finally {
store.destroy();
}
});

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/hassanzohdy/atom/stores/badge)](https://verified-skill.com/skills/hassanzohdy/atom/stores)

Something wrong with this skill or its page? Tell us.