In early March 2025 I experimented with embedding a React page in Electron in my electron_play workspace. These experiments were related to the later frontend integration in PromptPulse, but the directories at the time were my-electron-app and my-react-router-app. They aren't development records from the PromptPulse repository itself.1
I had a specific goal: open the built frontend directly in an Electron window without starting a web server just to display the page. Finding the HTML entry point wasn't enough: its JavaScript had to load too. I first tried changing build paths, then handling requests inside Electron. Along the way I also confused resource loading with page navigation.
How is loading a development server different from loading a local file?
On February 27 I read Azer Maslow's tutorial on Electron and React. Its example prepared two addresses for the same window. In development, loadURL opened http://localhost:3000. After packaging it still used loadURL, but with a file:// URL pointing to build/index.html. In the first case the page requests JS and CSS from the development server. In the second, relative paths resolve from the directory containing the local HTML.2
In the early hours of March 2 I also read Utku Yılmaz's tutorial on converting a React app to Electron. It makes the development dependency clear: one terminal starts the React dev server and another starts Electron, whose window opens the page served by the first using win.loadURL('http://localhost:3000').3
I wanted to open the built HTML directly with Electron's loadFile. Later that day I asked Cursor whether the build could generate JS references that read directly from local disk, then asked how to prefix a path with ..1
Here's an illustrative example, not the original filenames. Suppose the HTML lives at file:///opt/my-app/web/dist/index.html:
| Reference in the HTML | Resolved target |
|---|---|
/assets/app.js | file:///assets/app.js |
./assets/app.js | file:///opt/my-app/web/dist/assets/app.js |
The first starts at the filesystem root. The second starts in the HTML's directory. If the file actually lives under dist/assets, that distinction is decisive. Inspect both the artifact's location and the URL the page actually requests. An existing HTML entry point is no guarantee its assets can be found.
I also searched for Failed to load resource: net::ERR_FILE_NOT_FOUND in electron while loading spa locally and opened a related Stack Overflow question. Its HTML couldn't find Gridstack JS and CSS. The answer corrected the relative paths based on where the HTML and node_modules actually lived. Checking the directory relationship is transferable; the example's ../../ isn't something to copy blindly.4
Why didn't homepage in package.json work?
Cursor's suggestions included setting "homepage": "." in package.json. I repeatedly reported that the build paths hadn't changed, finally writing:
"homepage": ".", doesn't work for react router build
— My conversation with Cursor, original spelling retained.1
I also searched for homepage in package json react router build and visited “Using ‘homepage’ in package.json, without messing up paths for localhost”. The original question concerns asset paths in a Create React App deployment under a GitHub Pages subdirectory versus local development. A 2023 answer specifically distinguishes CRA's homepage from Vite's base.5
React is the UI library. The build tool reads the build configuration. Create React App reads homepage when generating asset paths. That doesn't mean every React project reads it. CRA's documentation also gives conditions for "homepage": ".", including not using HTML5 pushState routing. It isn't a universal switch for all client-side routing.6
Vite's corresponding option is base. In the Vite 6.1.0 documentation already available then, ./ was listed as an option for embedded deployment.7 So check the build command in package.json, the actual plugins, and the configuration file before choosing which option to change. Knowing only that it's a React project isn't enough.
Is a React Router or Remix project necessarily an SPA?
No. React Router can be a routing library inside your SPA or a framework in its own right. React Router 7.2.0's framework mode enables runtime server rendering by default. Setting ssr: false in react-router.config.ts enables its SPA mode. That mode still prerenders the root route at build time to generate index.html; the browser loads the code and hydrates it.8
So “SPA” doesn't mean “absolutely no prerendering or hydration.” For Electron integration, a more immediate question is: does this build still need a server at runtime? If it needs server-side rendering or server route logic, passing just the client directory to loadFile can't replace that server.
I called the project React Router (Remix) at the time. The conversation also referred to react-router.config.ts and build/client/index.html. But the surviving records don't show the ssr value in that configuration file. I can establish that I was trying to load frontend artifacts directly, but not that I had configured the entire framework for SPA mode.1
Even in an SPA, separate two path issues. Finding JS and CSS is an asset question. Returning the application entry point when someone enters or refreshes a route is a routing question. React Router's SPA deployment guide separately requires the host to direct application routes to index.html. Changing the asset base alone doesn't handle routing.8
I also looked at how an open-source client organized its pages, inspecting src/router/index.ts in Claude-Desktop. That project uses Vue Router's createWebHashHistory(import.meta.env.BASE_URL) for hash routing, then dynamically loads page components with () => import(...), including settings, prompts, and notes.9 Hash routing stores navigation state after the URL's #, a separate matter from where JS and CSS load. Dynamically loaded components still need valid asset paths. It's an example of UI organization, not evidence that I chose the same design for my React project.
Why didn't changing did-navigate address the problem either?
When the build paths didn't change as expected, I tried handling paths on the Electron side. Cursor suggested reloading the page in did-navigate, and I asked how to strip the file: prefix from a string. Then I explicitly corrected the target:
not on did navigate but on resource request
— My conversation with Cursor, original spelling retained.1
did-navigate reports that main-frame navigation has completed. It doesn't report every JS or CSS resource request, so modifying its handler doesn't directly correct all asset references on the page.10 The conversation turned to webRequest, but I still reported that the client's requests weren't being rewritten. This was an investigation, not a verified fix.1
The approaches discussed operated at different layers, which also matters in hindsight:
| Approach | Intended effect | Evidence from the time |
|---|---|---|
| Load the page over HTTP | Serve the page and assets from a server | I read tutorials and kept asking about direct local file loading. |
Change homepage | Generate relative asset paths at build time | I reported that it had no effect. |
| Change Webpack configuration or rewrite HTML after building | Adjust paths in the build or its output | Cursor suggested these; adoption unconfirmed. |
| Listen for navigation or try rewriting requests | Correct paths during Electron loading | I clarified the distinction between navigation and resource requests, then still reported no effect. |
Vite base: "./" with loadFile | Load static build assets with relative paths | A later PromptPulse commit contains the actual configuration. |
The most useful follow-up question was “Which layer decides this path?” The entry file path, asset URLs inside HTML, frontend routes, and backend API address each have their own place to configure them. Calling them all “a path problem” easily sends advice toward the wrong failing step.
What configuration did PromptPulse use later?
PromptPulse's March 4 commit used loadFile and a relative Vite base. The following two lines come from separate files at the time:11
// desktop/main.js
win.loadFile(path.join(__dirname, '../web/dist/index.html'))
// web/vite.config.js,defineConfig 中的一项
base:"./",
The same main process source still contains a commented-out did-navigate path rewriting snippet. The code establishes which loading configuration the later project used. I don't have a complete enough record to say how every issue in the earlier React Router experiment ended, and visiting an answer isn't the same as successfully applying it.11
For calling the main process from React through preload, see Interprocess communication and Electron IPC. Local service integration is covered in the PromptPulse development notes.
References
Footnotes
-
CaiBorui. (2025, March 2). Creating and Integrating a React App; Changing Base URL in Remix Router [Private development conversations with Cursor retained by the author]. Both the workspace configuration and conversation index point to
/home/borui/my_dev/electron_play, rather than the PromptPulse repository underneath it. Conversation IDs:3c26bdb1-781a-4d59-987d-c558a926be71and0ed80a68-370c-44b2-a367-31c592d23edc. Neighboring assistant responses discussing asset paths andhomepagedate to about 02:45–03:18 Beijing time. The response beside the other conversation's base URL question is around 03:49. User messages lack independent timestamps. The quotations come from feedback onhomepageand the correction to thedid-navigatesuggestion. AI suggestions do not establish adoption or successful repair. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 -
Maslow, A. (2023, July 21). Creating Desktop Applications with Electron and React [“Step 3: Configuring Electron,”
createWindowexample]. Medium. Tutorial. Access date: February 27, 2025. ↩ -
Yılmaz, U. (2024, May 4). Converting Your React App to an Electron Desktop App [main.js example in “Adding Electron to Your Project”]. Medium. https://medium.com/@utkuy.ceng/converting-your-react-app-to-an-electron-desktop-app-5efdafd15d7b . Firefox recorded a visit at 01:07:42 Beijing time on March 2, 2025. My recollection of the search sequence is
migrate remix to electron→migrate react to electron. The records also retain an earlierelectron with remixsearch and a later visit to theremix-electronsource. ↩ -
Zyaan. (2022, February 18). Electron - Failed to load resource: net::ERR_FILE_NOT_FOUND [Question]. Stack Overflow. https://stackoverflow.com/questions/71169408/electron-failed-to-load-resource-neterr-file-not-found . midnight-coding. (2022, February 19). Answer to “Electron - Failed to load resource: net::ERR_FILE_NOT_FOUND” [Edited February 22, 2022, section on relative HTML asset paths]. Stack Overflow. https://stackoverflow.com/a/71185154 . Access date: June 8, 2025. Entry point: Google search. Local conversations confirm similar asset path investigation but do not contain the complete error text. ↩
-
tscizzle. (2017, March 25). Using “homepage” in package.json, without messing up paths for localhost [Question]. Stack Overflow. https://stackoverflow.com/questions/43011207/using-homepage-in-package-json-without-messing-up-paths-for-localhost . Maki, R. (2023, November 10). Answer to “Using ‘homepage’ in package.json, without messing up paths for localhost” [Edited November 11, 2023]. Stack Overflow. https://stackoverflow.com/a/77457359 . Access date: June 8, 2025. Search supplied by the author:
homepage in package json react router build. Which specific answer I read then is unconfirmed. ↩ -
Create React App contributors. (n.d.). Deployment [“Building for Relative Paths” and “Serving the Same Build from Different Paths”]. Create React App documentation. https://create-react-app.dev/docs/deployment/#building-for-relative-paths . Checked November 18, 2026 to explain the scope of
homepage; not recorded as a historical visit. ↩ -
Vite contributors. (n.d.). Shared Options: base [Pinned Vite v6.1.0 documentation]. GitHub. https://github.com/vitejs/vite/blob/v6.1.0/docs/config/shared-options.md#base . Checked November 18, 2026 to establish the meaning of an option available at the time; not evidence of the precise Vite version used in the experiment. ↩
-
React Router contributors. (n.d.). Single Page App (SPA) [Pinned 7.2.0 documentation, “Overview”, “Disable Runtime Server Rendering”, and “Direct all URLs to index.html”]. GitHub. https://github.com/remix-run/react-router/blob/react-router%407.2.0/docs/how-to/spa.md . Checked November 18, 2026 to explain the historical framework capability, not as confirmation of local configuration. ↩ ↩2
-
Karenina-na et al. (n.d.). Claude-Desktop: src/router/index.ts [Historical snapshot 85cb591]. GitHub. Original browsing entry: https://github.com/Karenina-na/Claude-Desktop/blob/master/src/router/index.ts ; pinned snapshot. Router source read for comparison. Whether the main interest was hash routing, page organization, or dynamic loading isn't established, nor is a precise visit date. Access date: June 8, 2025. ↩
-
Electron contributors. (n.d.). webContents [Pinned Electron v34.3.0 documentation, Event: did-navigate]. GitHub. https://github.com/electron/electron/blob/v34.3.0/docs/api/web-contents.md#event-did-navigate . Checked November 18, 2026. ↩
-
CaiBorui [S2thend]. (2025, March 4). PromptPulse [Commit 32c04f1]. GitHub. desktop/main.js, web/vite.config.js. Shows local page loading, the commented navigation rewrite, and
base: "./". It doesn't establish that every problem in the early experiment was resolved. ↩ ↩2