{"slug": "turning-a-claude-artifact-into-a-macos-and-windows-app-with-electron", "title": "Turning a Claude artifact into a macOS and Windows app with Electron", "summary": "A developer documented a roughly 45-minute workflow for turning a Claude artifact into a native desktop application by wrapping the exported HTML in Electron and packaging it with electron-builder. The approach produces macOS .dmg and .zip builds and Windows NSIS and portable .exe installers from a three-file project, with contextIsolation enabled and nodeIntegration disabled so the artifact's scripts cannot reach Node APIs. The developer notes that React/JSX snippets require a separate build step before wrapping.", "body_md": "Claude artifacts are handy for prototyping, but they stay locked inside a chat panel. If you want to hand someone a real desktop icon — a window that opens on macOS and Windows with no browser around it — you don't have to rewrite the code. Wrapping the exported HTML in Electron and letting electron-builder handle packaging gets you there.\n\nI ran through this with a small artifact recently. It took me about 45 minutes end to end, including two dead ends. Here's the path I'd take again.\n\nAfter roughly 40–60 minutes you have a folder `claude-artifact-app/` with three moving parts: `index.html` (your exported artifact), `main.js` (the desktop shell), and `package.json` with a `build` block. `npm start` opens it as a native window; `npm run dist` drops installers into `dist/` — a `.dmg` plus `.zip` for macOS, an NSIS `.exe` and a portable `.exe` for Windows.\n\nPrerequisites:\n\n`node -v` and `npm -v` should both print a version)`npm install`\nDifficulty sits at intermediate: you'll edit one JSON file and create one JS file.\n\nOpen the artifact in Claude and use the copy or download control in the panel, saving the result as `claude-artifact-app/index.html`. The label on that control moves around between plans and UI versions, so if you can't find a download option, select the code and paste it into a file yourself.\n\nThe reason it has to be self-contained: the shell loads a local file. There's no server behind it, so whatever you export is the entire front end.\n\nVerify it in a browser before Electron enters the picture:\n\n```\ncd claude-artifact-app\npython3 -m http.server 8080\n```\n\nNow open `http://localhost:8080/index.html`. The layout and buttons should match the artifact panel exactly. Click the main interactive element — a form, a calculator, whatever you built — and confirm it reacts. `Ctrl+C` stops the server.\n\nOne caveat: if what you have is a React/JSX snippet rather than a complete HTML document, you need a build step (Vite or similar) first. That's ordinary web-app territory, not an Electron problem.\n\nElectron is the runtime that renders HTML inside a native window; electron-builder is what turns that into installers.\n\n```\nnpm init -y\nnpm install --save-dev electron@latest electron-builder@latest\n```\n\nThen create `main.js`:\n\n``` js\nconst { app, BrowserWindow } = require('electron');\n\nfunction createWindow() {\n  const win = new BrowserWindow({\n    width: 1200,\n    height: 800,\n    webPreferences: { contextIsolation: true, nodeIntegration: false }\n  });\n  win.loadFile('index.html');\n}\n\napp.whenReady().then(createWindow);\napp.on('window-all-closed', () => app.quit());\n```\n\nOn Windows you can't use the bash heredoc in PowerShell, so write the file like this instead:\n\n```\n@'\n... same main.js content as above ...\n'@ | Set-Content -Encoding UTF8 main.js\n```\n\nNext, replace the generated `package.json`, keeping the `name`, `version` and dependency versions npm already wrote:\n\n```\n{\n  \"name\": \"claude-artifact-app\",\n  \"version\": \"1.0.0\",\n  \"main\": \"main.js\",\n  \"scripts\": {\n    \"start\": \"electron .\",\n    \"dist\": \"electron-builder\"\n  },\n  \"build\": {\n    \"appId\": \"org.example.artifactapp\",\n    \"files\": [\"main.js\", \"index.html\", \"assets/**/*\"],\n    \"mac\": { \"target\": [\"dmg\", \"zip\"], \"category\": \"public.app-category.productivity\" },\n    \"win\": { \"target\": [\"nsis\", \"portable\"] }\n  },\n  \"devDependencies\": {}\n}\n```\n\nTwo fields carry the weight. `main` tells Electron which file opens the window. `files` is the whitelist the packager works from — anything missing from that array (npm sources, test files) simply won't exist inside the installer. Meanwhile `contextIsolation: true` together with `nodeIntegration: false` blocks the artifact's scripts from reaching Node APIs, so pasted code can't walk the filesystem.\n\nTest the shell:\n\n```\nnpm start\n```\n\nWhen it works, a native window appears with your artifact inside. Hit `View → Toggle Developer Tools` and look at the Console tab — no red errors should be there. `Ctrl+C` in the terminal shuts it down.\n\n```\nnpm run dist\n```\n\nelectron-builder reads that `build` block, bundles the Electron runtime with your files, and emits platform-native packages: a disk image macOS users drag the app out of, and the standard Windows setup wizard. Look before you install:\n\n```\nls -1 dist\n```\n\nExpect the packaged app directory plus files derived from your `name` and `version` values — something like `claude-artifact-app-1.0.0.dmg`, a `-mac.zip`, a `Setup 1.0.0.exe`, and a portable `.exe`.\n\nAbout cross-building: macOS → Windows needs extra tooling, so the shortest route is running the build on each OS you target.\n\n`npm start` renders the artifact with a clean Console`dist/` holds both a macOS and a Windows artifact`http://localhost:8080` still works in the window`assets/`\nInstalling your own build is easy: double-click the `.dmg` and drag the app into Applications on macOS; run the `Setup .exe` on Windows.\n\n**Electron won't install and `npm start` dies instantly.** The message is `Error: Electron failed to install correctly, please delete node_modules/electron and try installing again`. The post-install binary download got blocked by a proxy, a corporate firewall, or a half-written cache. Clear it and retry:\n\n```\nrm -rf node_modules/electron\nnpm cache clean --force\nnpm install --save-dev electron@latest\n```\n\nBehind a company network, export `HTTPS_PROXY` before installing.\n\n**The window opens but the content area is blank white.** DevTools reports `Not allowed to load local resource: file:///...` or a failed `GET` for a CDN script. Either the artifact references assets by absolute path (`/assets/app.js`) or it pulls a library the packaged app can't fetch. Switch those to relative paths (`./assets/app.js`), move the files into `assets/`, confirm `assets/**/*` appears in the `files` array, then run `npm run dist` again.\n\n**The operating system refuses to launch the installed app.** macOS claims the developer cannot be verified; Windows shows \"Windows protected your PC\" with a `Don't run` button. Both are just the unsigned-build penalty. For personal use, right-click the app and choose `Open` on macOS, or click `More info → Run anyway` on Windows. If you plan to distribute it, sign and notarize — read Apple's and Microsoft's current signing docs, because the electron-builder flags shift between releases.\n\nThe artifact was already a web app; Electron only contributes a window and a packager. Export it, prove it works in a browser first, keep the `files` whitelist tight, and build on every OS you intend to support. Code signing is the last mile, and for personal use you can skip it.\n\nThis article was originally published on AI Release — [https://ai-release.org](https://ai-release.org). If you want more walkthroughs like this one, they also show up in the Telegram channel: [https://t.me/ai_release1](https://t.me/ai_release1).", "url": "https://wpnews.pro/news/turning-a-claude-artifact-into-a-macos-and-windows-app-with-electron", "canonical_source": "https://dev.to/qunirice_verase_1ab0caeba/turning-a-claude-artifact-into-a-macos-and-windows-app-with-electron-10a1", "published_at": "2026-11-26 10:06:55+00:00", "updated_at": "2026-11-26 10:14:13.841575+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-products"], "entities": ["Claude", "Electron", "electron-builder", "Anthropic", "Vite"], "also_reported_by": [], "takeaway": "Wrapping an exported self-contained HTML artifact in Electron with contextIsolation: true and nodeIntegration: false, then packaging via electron-builder's files whitelist, yields macOS and Windows installers in about 45 minutes without rewriting the code.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/turning-a-claude-artifact-into-a-macos-and-windows-app-with-electron", "markdown": "https://wpnews.pro/news/turning-a-claude-artifact-into-a-macos-and-windows-app-with-electron.md", "text": "https://wpnews.pro/news/turning-a-claude-artifact-into-a-macos-and-windows-app-with-electron.txt", "jsonld": "https://wpnews.pro/news/turning-a-claude-artifact-into-a-macos-and-windows-app-with-electron.jsonld"}}