{
  "id": "98cfefa5909035fe892680e2",
  "source": "solid:signals",
  "type": "github-document",
  "title": "produce",
  "content": "---\ntitle: produce\nuse_cases: \u003e-\n  immutable updates, immer-style mutations, store modifications, complex state\n  changes, nested updates\ntags:\n  - store\n  - immutable\n  - updates\n  - immer\n  - mutations\nversion: '1.0'\ndescription: \u003e-\n  Use Immer-inspired produce API to mutate Solid stores immutably. Simplify\n  complex nested updates with familiar mutation syntax.\n---\n\n`produce` is an [Immer](https://immerjs.github.io/immer/) inspired API for Solid's Store objects that allows the store to be mutated inside the `produce` function.\n\n```ts\nimport { produce } from \"solid-js/store\"\nimport type { NotWrappable, Store } from \"solid-js/store\"\n\nfunction produce\u003cT\u003e(\n\tfn: (state: T) =\u003e void\n): (\n\tstate: T extends NotWrappable ? T : Store\u003cT\u003e\n) =\u003e T extends NotWrappable ? T : Store\u003cT\u003e;\n```\n\nFor use with `createStore`:\n\n```tsx\nimport { produce } from \"solid-js/store\";\n\nconst [state, setState] = createStore({\n\tuser: {\n\t\tname: \"John\",\n\t\tage: 30,\n\t},\n\tlist: [\"book\", \"pen\"],\n});\n\nsetState(\n\tproduce((state) =\u003e {\n\t\tstate.user.name = \"Jane\";\n\t\tstate.list.push(\"pencil\");\n\t})\n);\n```",
  "url": "https://github.com/solidjs/solid-docs/blob/HEAD/src/routes/reference/store-utilities/produce.mdx",
  "metadata": {
    "path": "src/routes/reference/store-utilities/produce.mdx",
    "repo": "solidjs/solid-docs",
    "repo_url": "https://github.com/solidjs/solid-docs.git",
    "size": 1076,
    "source_type": "github"
  },
  "hash": "89ebe9b805d26ea1a0057db4f3d3725c108e9ff6ae6d134a77eac7195de21245",
  "timestamp": "2026-02-23T11:43:00.190898161+01:00"
}