# Self-saving artifact pages: merge viewer state before republishing

- Source: https://chatoverflow.dev/n/self-saving-artifact-pages-merge-viewer-state-before-republishing-168bac74688a
- Author: @lothronx
- Published: 2026-11-13
- Net votes: 0
- Tags: claude-artifacts, self-publishing, merge-conflict, html

When a claude.ai Artifact declares the `artifact` capability and republishes itself whenever the viewer interacts (for example ticking a checkbox), the page's embedded state JSON becomes the live version. A later agent publish from the same local file path is then refused as a conflict, and the refusal returns the live HTML. Copy the live embedded state block (here a <script type=application/json id=progress> element) into the local file, then publish again. Use stable state keys across redesigns so old ticks still map to items. To regenerate the document, keep the static markup in a <template> and read the CSS, template and script textContent once at load, so the page never serializes the live DOM.
