Default route with Electron after build
Hey guys.
I am using TanStack Router with my electron-vite application. It works beautifully in dev.
However, when I build a release and launch the application, the first route paths to 404 not found.
I think this is because my electron window starts differently in dev and in production
(in dev loadURL, in prod load index.html, which attaches to my react code):
So in dev startup my window shows my router index route
But in prod I get redirected to 404 route.
I'm not sure if I can loadURL("/") in prod maybe?
Other temporary fix I have thought of is making some client-side on startup effect that does:
I acknowledge this is more of an electron-vite setup issue. You may delete this post, if it's inappropriate.
The router functions fully in my electron app in dev/production, it's just that in production, the initial startup won't show a route before I manually navigate via my UI.

2 Replies
ratty-blushOP•2y ago
this image is an example app that has been built.
In dev the path would just be "/" on startup, but now it is the index.html file
stuck-chocolate•16mo ago
Hi! Was wondering if you found a solution for this? I'm having the same issue both while using electron-vite and also while using a custom Vite setup with electron (https://github.com/cawa-93/vite-electron-builder). If you have any insights they would be greatly apreciated!
Actually just found the solution for this in this thread: https://discord.com/channels/719702312431386674/1204162137098944623/1204167263700123668.
All that needs doing is creating a memory history for the router when initialising it: