Adding and calling custom javscript to electron .net app #900

Closed
opened 2026-01-29 16:51:34 +00:00 by claunia · 2 comments
Owner

Originally created by @domingoladron on GitHub (Jun 18, 2023).

Originally assigned to: @GregorBiswanger on GitHub.

Hey there,

I want to hook right into the electron engine via Javascript using npm etc. How do I

  1. Add code which should be loaded and run by the base electron system?
  2. Ensure this code is loaded up when the app is built / started?
  3. Call such custom code from the electron.net APIs?

I have been trying to piece it all together, but so many moving parts and I just would like a bit of clarity so I can do this right.

Cheers

Originally created by @domingoladron on GitHub (Jun 18, 2023). Originally assigned to: @GregorBiswanger on GitHub. Hey there, I want to hook right into the electron engine via Javascript using npm etc. How do I 1. Add code which should be loaded and run by the base electron system? 2. Ensure this code is loaded up when the app is built / started? 3. Call such custom code from the electron.net APIs? I have been trying to piece it all together, but so many moving parts and I just would like a bit of clarity so I can do this right. Cheers
claunia added the question label 2026-01-29 16:51:34 +00:00
Author
Owner

@GregorBiswanger commented on GitHub (Jun 20, 2023):

For this, we have the HostHook feature, which needs to be activated via the Electron.NET-CLI with the following command: electronize add hosthook

This will create an ElectronHostHook directory in your project. Ideally, you can now open this with Visual Studio Code. Install NPM packages and communicate with the actual application.

Our Electron.NET API Demo App and its source code will show you exactly how to do this:
https://github.com/ElectronNET/electron.net-api-demos

https://github.com/ElectronNET/electron.net-api-demos/blob/master/ElectronNET-API-Demos/Controllers/HostHookController.cs

https://github.com/ElectronNET/electron.net-api-demos/tree/master/ElectronNET-API-Demos/ElectronHostHook

Was I able to assist you with this?

@GregorBiswanger commented on GitHub (Jun 20, 2023): For this, we have the HostHook feature, which needs to be activated via the Electron.NET-CLI with the following command: `electronize add hosthook` This will create an `ElectronHostHook` directory in your project. Ideally, you can now open this with Visual Studio Code. Install NPM packages and communicate with the actual application. Our **Electron.NET API Demo App** and its source code will show you exactly how to do this: https://github.com/ElectronNET/electron.net-api-demos https://github.com/ElectronNET/electron.net-api-demos/blob/master/ElectronNET-API-Demos/Controllers/HostHookController.cs https://github.com/ElectronNET/electron.net-api-demos/tree/master/ElectronNET-API-Demos/ElectronHostHook Was I able to assist you with this?
Author
Owner

@domingoladron commented on GitHub (Jun 20, 2023):

That's exactly what I was after. Thanks so much.

Once I get my head around it and am able to do the basics, would y'all be amenable to a documentation PR with details on how to do this for others? This seems like a useful scenario for devs, as some stuff is just easier to do in javascript / typescript / electron than in Blazor.

If a documentation PR would be acceptable, do you have a preferred place (README.md?) for such docs?

Let me know and cheers for the assist

@domingoladron commented on GitHub (Jun 20, 2023): That's exactly what I was after. Thanks so much. Once I get my head around it and am able to do the basics, would y'all be amenable to a documentation PR with details on how to do this for others? This seems like a useful scenario for devs, as some stuff is just easier to do in javascript / typescript / electron than in Blazor. If a documentation PR would be acceptable, do you have a preferred place (README.md?) for such docs? Let me know and cheers for the assist
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#900