{"id":19792880,"url":"https://github.com/handtrix/next-electron-server","last_synced_at":"2025-07-06T22:10:21.222Z","repository":{"id":43676434,"uuid":"299617538","full_name":"HaNdTriX/next-electron-server","owner":"HaNdTriX","description":"Server your Next.js app inside electron using a custom scheme.","archived":false,"fork":false,"pushed_at":"2023-12-26T21:55:33.000Z","size":305,"stargazers_count":27,"open_issues_count":4,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-21T05:40:39.104Z","etag":null,"topics":["electron","nextjs","react"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/next-electron-server","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HaNdTriX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-29T12:56:41.000Z","updated_at":"2024-09-08T03:37:06.000Z","dependencies_parsed_at":"2024-06-19T05:30:17.421Z","dependency_job_id":"345dfdee-e90b-46d0-a788-963d00b6de3a","html_url":"https://github.com/HaNdTriX/next-electron-server","commit_stats":{"total_commits":54,"total_committers":3,"mean_commits":18.0,"dds":0.5,"last_synced_commit":"88d9fcca55799caa408b18f31faf9cf0238af488"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/HaNdTriX/next-electron-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaNdTriX%2Fnext-electron-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaNdTriX%2Fnext-electron-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaNdTriX%2Fnext-electron-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaNdTriX%2Fnext-electron-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HaNdTriX","download_url":"https://codeload.github.com/HaNdTriX/next-electron-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HaNdTriX%2Fnext-electron-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263980177,"owners_count":23538922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","nextjs","react"],"created_at":"2024-11-12T07:08:13.262Z","updated_at":"2025-07-06T22:10:21.181Z","avatar_url":"https://github.com/HaNdTriX.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Next.js Electron Server\n\nServe your [Next.js](https://nextjs.org/) app inside [Electron](https://www.electronjs.org/) using a custom scheme.\n\n## Install\n\n```js\n$ npm install next-electron-server\n```\n\nor using [yarn](https://yarnpkg.com/)\n\n```js\n$ yarn add next-electron-server\n```\n\n## Usage\n\n```js\nconst serveNextAt = require(\"next-electron-server\");\n\nserveNextAt(\"next://app\");\n\napp.on(\"ready\", async () =\u003e {\n  const mainWindow = new BrowserWindow({\n    width: 800,\n    height: 600,\n  });\n\n  mainWindow.loadURL(\"next://app\");\n  // mainWindow.loadURL(\"next://app/page1\");\n  // mainWindow.loadURL(\"next://app/page2\");\n});\n```\n\nFor more infos check out the [example](./example) directory.\n\n## Motivation\n\nMost electron tutorials recommend using a url switch to differentiate between devserver localhost urls in development and static urls used in production:\n\n```js\napp.on(\"ready\", async () =\u003e {\n  const mainWindow = new BrowserWindow({\n    width: 800,\n    height: 600,\n  });\n\n  const url = isDev\n    ? \"http://localhost:8000\"\n    : format({\n        pathname: join(__dirname, \"../renderer/out/index.html\"),\n        protocol: \"file:\",\n        slashes: true,\n      });\n\n  mainWindow.loadURL(url);\n});\n```\n\nFrom my point of view this approach has many drawbacks.\n\n- The origin of the html document differs between production \u0026 development\n- The security model may differ between production \u0026 development\n- Paths differ between production \u0026 development\n- 404 pages won't work in production\n\nThat's why I created `next-electron-server`.\nThe render page will always being served using the same protocol and url.\n\n- In **development** is implements a proxy to `http://localhost:3000`.\n- In **production** is serves files from the `/out` directory.\n\n## Features\n\n- supports 404 pages\n- works with Next.js dev-server\n- waits for Next.j dev-server to start\n- works with paths of images and other static resources\n- static paths won't differ between development and production\n- has zero dependencies\n\n## API\n\n### serveNextAt(uri, options)\n\n#### uri\n\n_Required_\\\nType: `string`\\\nExample: `next://app`\n\nThe entry-point of your Next.js app.\n\n#### options\n\nType: `object`\n\n##### ↳ outputDir\n\nType: `string`\\\nDefault: `\"./out\"`\n\nThe directory to serve, relative to the app root directory.\n\n##### ↳ port\n\nType: `number`\\\nDefault: `3000`\n\nThe port your Next.js dev-server runs on.\n\n##### ↳ dev\n\nType: `boolean`\\\nDefault `!app.isPackaged`\n\nThis flag decides how to serve the files. When `dev === true` a proxy will be created pointing to `localhost:3000`.\n\n##### ↳ privileges\n\nType: `object`\n\nCheck out [electron/docs/protocol](https://www.electronjs.org/docs/api/protocol#protocolregisterschemesasprivilegedcustomschemes) for more infos about this config object.\n\n##### ↳ partition\n\nType: `string`\\\nDefault: [`electron.session.defaultSession`](https://www.electronjs.org/docs/latest/api/session#sessiondefaultsession)\n\nThe partition the protocol should be installed to, if you're not using Electron's default partition.\n\n## Contributing\n\n1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device\n2. Link it to the global module directory: `yarn link`\n3. Install in your local project using `yarn link next-electron-server`\n\n## Author\n\nHenrik Wenz ([@HenrikWenz](https://twitter.com/henrikwenz))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhandtrix%2Fnext-electron-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhandtrix%2Fnext-electron-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhandtrix%2Fnext-electron-server/lists"}