nextjs-to-electron
БесплатноЗапускает вложенные скриптыНе проверенUse when converting a Next.js static export into a Windows Electron desktop app, especially for offline machines without WebView2. Next.js 转 Windows Electron…
от rockbenben1 251 установка в других каталогахОб этом скилле
Next.js → Electron Desktop App
Overview
Wrap a static-exportable Next.js (App Router) app in a thin Electron shell. Electron bundles its own Chromium, so unlike Tauri it needs no system WebView2 — the reason to pick it for locked-down/intranet machines. Keep the web behavior intact and put shell-specific behavior in electron/. Make the source or configuration changes required for a working export.
Core principle: Serve the export over a custom app:// protocol, NOT file://. Almost all migration pain is path/origin resolution, not React — and file:// silently breaks both. (See electron-files.md for all copy-paste code.)
When to use
- The app is (or can be) a static export (
output: "export") — diff/format/calculator/viewer tools, no SSR or API-at-runtime. - Export prerequisites:
output: "export"innext.config.*. The defaultnext/imageoptimizer needs a server; useimages.unoptimized: truefor the offline template, or retain an export-compatible custom loader after verifying its network requirements. - You want a Windows desktop build that runs fully offline, especially where WebView2 is absent (LTSC/Server images, air-gapped intranet) so Tauri won't launch.
Check platform and toolchain compatibility. Confirm the target Windows version and architecture against the selected Electron release. Use a supported stable Electron line and compatible builder/updater versions from the project's package source; old release asset inventories do not establish current support.
For CI, select a supported Node version that satisfies the build tools' engines. An explicit Active LTS major is a reproducible default; retain a deliberate project pin policy. engines.node expresses compatibility, not simply the CI version. See Electron releases and the Node schedule.
Runtime API routes, SSR and server actions need a separately assessed server/sidecar design. Consider nextjs-to-tauri when a system WebView is acceptable; measure package sizes from actual artifacts. Maintenance of an existing Electron app uses desktop-app-standard rather than repeating this migration.
Build-time Server Components and statically generated GET handlers can remain; do not convert them all to "use client". Verify that their data is emitted into the export and does not need a runtime Next.js server. See static-export support.
This playbook targets Windows (--win dir/portable, SmartScreen, WebView2-less boxes). macOS/Linux packaging (.dmg/.AppImage, notarization, codesigning) is out of scope.
Local migration covers the necessary source/configuration changes. Remote tags, public releases and signing-service setup follow the user's authorized scope; a read-only assessment reports blockers and proposed checks without installing or building.
Procedure
Adapt the following steps to the repository. Full code is in electron-files.md. Preserve existing web behavior and make only necessary export or desktop integration changes. Commands use yarn; in an npm or pnpm repo substitute the equivalent (npm ci for yarn install --frozen-lockfile) and match setup-node's cache: to the lockfile you actually have — cache: yarn fails the job outright when there is no yarn.lock.
Confirm the export is client-side and check its shape.
yarn build, thenls out/— you'll see flat files (index.html,en.html,zh.html) and_next/.trailingSlash: false(flat files) is fine; the resolver handles both layouts (gotcha #2). If the build stops on the default image loader, that is theimages.unoptimizedprerequisite above — set it and rebuild.Add the toolchain (after the version check above):
yarn add -D electron electron-builder. Inpackage.jsonadd"main": "electron/main.js"and scripts:electron:dev(node scripts/electron-dev.cjs, which setsELECTRON_DEV=1and spawns electron),electron:build(next build && electron-builder --win dir),test:electron(list the test files explicitly —node --test electron/resolvePath.test.js electron/store.test.js …; choose a glob only when the project Node/shell supports it, gotcha #5). Addelectron/package.jsonwith{"type":"commonjs"}so the shell and its tests also run when the Next.js project's root declares"type": "module".Create the
electron/layer (copy from electron-files.md). Split into pure modules that must NOTrequire("electron")(sonode --testruns them) and Electron-bound ones:constants.js—SCHEME="app",LOCALES[].resolvePath.js—resolveAssetPath(outDir, pathname, exists)with.html→/index.html→404.htmlfallback.store.js— dependency-free JSON store inuserData.locale.js—startUrl/parseLocale/`track
Установить nextjs-to-electron в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл nextjs-to-electron?
Use when converting a Next.js static export into a Windows Electron desktop app, especially for offline machines without WebView2. Next.js 转 Windows Electron / 将 Next.js 静态导出打包成 exe. Confirm the project supports static export and Windows Electron is the intended target.
Как установить скилл nextjs-to-electron?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл nextjs-to-electron запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic