T
TanStack10mo ago
afraid-scarlet

Electron app integration

I got Router working with Electron and now I'm trying to do the same with Start. The entry point with Electron is index.html
<script type="module" src="/src/main.tsx"></script>
There is no src/main.tsx with Start. What would be the correct substitute? Or do I need to go further up the chain and direct Electron to the correct start entry point? Thanks
4 Replies
afraid-scarlet
afraid-scarletOP10mo ago
I see in electron, there is a reference to the index.html
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
How to change that? This is so cursed. In src/main/index.ts
// HMR for renderer base on electron-vite cli.
// Load the remote URL for development or the local html file for production.
if (is.dev && process.env.ELECTRON_RENDERER_URL) {
// mainWindow.loadURL(process.env.ELECTRON_RENDERER_URL);
mainWindow.loadURL('http://localhost:3000');
} else {
mainWindow.loadFile(join(__dirname, '../renderer/index.html'));
}
// HMR for renderer base on electron-vite cli.
// Load the remote URL for development or the local html file for production.
if (is.dev && process.env.ELECTRON_RENDERER_URL) {
// mainWindow.loadURL(process.env.ELECTRON_RENDERER_URL);
mainWindow.loadURL('http://localhost:3000');
} else {
mainWindow.loadFile(join(__dirname, '../renderer/index.html'));
}
I'm running start natively, then I run electron natively. Electron hits an endpoint instead of index.html.
generous-apricot
generous-apricot10mo ago
This is cool is it possible to call electron api inside of server functions?
afraid-scarlet
afraid-scarletOP10mo ago
That I don't know just yet. I will come back to this thread and yet you know when I get to that point.
rival-black
rival-black10mo ago
i don't know if this can be helpful, but i remember that the remix community had a prototype of remix + electron with loader / action accessing electron api https://github.com/itsMapleLeaf/remix-electron
GitHub
GitHub - itsMapleLeaf/remix-electron: Electron integration for Remi...
Electron integration for Remix ⚛💿. Contribute to itsMapleLeaf/remix-electron development by creating an account on GitHub.

Did you find this page helpful?