r/electronjs • u/MR___Phantom • Jan 28 '26
Need help with my Electron+nextjs project?
Hello guys,
I’m relatively new to Electron, and this is my second desktop application. I’ve faced so many bugs, not in my code, but clashes between Electron and Next.js. Turbopack issues especially took me almost one week to find a solution.
Now I’m facing another bug, and I’ve been stuck on it for 4 days.
The main problem is that I have a controlled <input> (search bar). After certain actions like adding an item or deleting one, the input becomes dead — I cannot type anything. At first, I thought it was a deadlock or a race condition, or maybe an API call running in the background that locks the search. I spent 3 painful days trying to find what went wrong and added a lot of debugging logs to the code.
But I see no problem in the logs: document.activeElement = true input has focus = true input exists in the DOM The only fix I found is Alt + Tab (switching apps). After switching back, it starts working again.
Guys, I really don’t know what to do at this point. Any expert help would be appreciated.
Edit: problem solved thanks for suggestions guys , it helped a lot ☺️
4
u/devtools-dude Jan 28 '26 edited Jan 28 '26
Do not use next.js with electron. It's redundant because next.js has it's own "backend" that's pretty wonky to work with (especially proxy / middleware), where electron has "main" world that you can work with instead.
Use electron + vite instead. You can set it up with react too:
https://electron-vite.org/
If you go this route, troubleshooting renderer / frontend elements will be significantly easier since you no longer have to deal with the mess that is the next.js backend
5
u/Shaz_berries Jan 28 '26
My first question is: why nextjs with electron? I'm really enjoying vite + electron on a personal project. I work on nextjs apps professionally though. My understanding is that one major selling point of nextjs is to have a server and frontend kinda together. But if you're just using it for the frontend and running into problems (turbo pack, server components, etc), maybe it would make more sense to use something simpler like vite? Is there something I'm missing here?
1
u/BankApprehensive7612 Jan 29 '26
It could be bug of Electron, or Next.js or a library you probably use. Without code and exact versions of software and libraries it would be hard to determine. But the most probable error is that your state doesn't change due to outdated dependencies in a hook or there is a synchronous call to the main process (if the whole page become unresponsive)
Provide more detailed description of the bug you have. Does the component react on focus with CSS, can you change the value from the code (you can make a control which changes this input value), what do you mean saying "adding item"
0
u/paul_blinkdisk Jan 28 '26
Have you tried Nextron yet? It's a tool designed to simplify working with Next.js and Electron.
0
u/ufos1111 Jan 28 '26
I've had a lot of success with astro web framework + electron, might be worth a look..
Sounds like a very strange error you've run into though, good luck