cd /news/ai-tools/turning-a-claude-artifact-into-a-mac… · home › topics › ai-tools › article
[ARTICLE · art-176703] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

Turning a Claude artifact into a macOS and Windows app with Electron

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.

key 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.

by read5 min views5 publishedNov 26, 2026

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.

I 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.

After 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.

Prerequisites:

node -v and npm -v should both print a version)npm install Difficulty sits at intermediate: you'll edit one JSON file and create one JS file.

Open 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.

The 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.

Verify it in a browser before Electron enters the picture:

cd claude-artifact-app
python3 -m http.server 8080

Now 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.

One 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.

Electron is the runtime that renders HTML inside a native window; electron-builder is what turns that into installers.

npm init -y
npm install --save-dev electron@latest electron-builder@latest

Then create main.js:

const { app, BrowserWindow } = require('electron');

function createWindow() {
  const win = new BrowserWindow({
    width: 1200,
    height: 800,
    webPreferences: { contextIsolation: true, nodeIntegration: false }
  });
  win.loadFile('index.html');
}

app.whenReady().then(createWindow);
app.on('window-all-closed', () => app.quit());

On Windows you can't use the bash heredoc in PowerShell, so write the file like this instead:

@'
... same main.js content as above ...
'@ | Set-Content -Encoding UTF8 main.js

Next, replace the generated package.json, keeping the name, version and dependency versions npm already wrote:

{
  "name": "claude-artifact-app",
  "version": "1.0.0",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "dist": "electron-builder"
  },
  "build": {
    "appId": "org.example.artifactapp",
    "files": ["main.js", "index.html", "assets/**/*"],
    "mac": { "target": ["dmg", "zip"], "category": "public.app-category.productivity" },
    "win": { "target": ["nsis", "portable"] }
  },
  "devDependencies": {}
}

Two 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.

Test the shell:

npm start

When 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.

npm run dist

electron-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:

ls -1 dist

Expect 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.

About cross-building: macOS → Windows needs extra tooling, so the shortest route is running the build on each OS you target.

npm start renders the artifact with a clean Consoledist/ holds both a macOS and a Windows artifacthttp://localhost:8080 still works in the windowassets/ Installing your own build is easy: double-click the .dmg and drag the app into Applications on macOS; run the Setup .exe on Windows.

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:

rm -rf node_modules/electron
npm cache clean --force
npm install --save-dev electron@latest

Behind a company network, export HTTPS_PROXY before installing.

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.

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.

The 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.

This article was originally published on AI Release — 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.

── more in #ai-tools 4 stories · sorted by recency
── more on @claude 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/turning-a-claude-art…] indexed:0 read:5min 2026-11-26 · —