mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
Document custom_main.js #1018
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @softworkz on GitHub (Nov 20, 2025).
Document the possibility of adding a custom_main.js file which will be execute before Electron initialization
Provide a sample.
Maybe we should create a new repositoty for publishing app samples.
(and eventually mark the current ones as archived)
@niteshsinghal85 commented on GitHub (Dec 6, 2025):
Hi @FlorianRappl , @softworkz
I’m interested in working on this issue and contributing for a sample/documentation about usage of
custom_main.js.Before I start implementation, I’d like to confirm your expectations:
custom_main.jsusage), or a more complete app sample?Once I have your guidance, I’ll be happy to start drafting the sample and documentation.
Thanks!
@softworkz commented on GitHub (Dec 6, 2025):
Thinking about it more, I see two sides:
So, maybe we should do both: Have the samples in the main repo and on every release, we copy them over to a samples repo, where we are creating a new branch for each release - so users will be able to use the branch selector in the samples repo to choose the version for which they want to get samples.
This would also give us freedom to add or drop samples without causing any confusion. What I mean is for example, a sample like this: https://github.com/ElectronNET/electron.net-musicplayer-sample which is no longer maintained can be removed and it's just no more visible (as long as somebofy would switch to an old versiion branch in the samples repo.
@FlorianRappl commented on GitHub (Dec 6, 2025):
I agree with @softworkz but to keep things simple let's integrate them in this repo to the existing docs.
Minimal is sufficient in my opinion. However, the more you like to show / document the better.
I have nothing in my mind (env. variables is a great scenario to cover), so you have as much freedom as you like.
@niteshsinghal85 commented on GitHub (Dec 6, 2025):
@FlorianRappl
ok then I start working on this.
@softworkz commented on GitHub (Dec 6, 2025):
A good example for a use case might be the case that had recently been brought up, which is about registering protcol handlers (like
custom://abcde). This has to be done before initialization of the Electron app.Another example would be about setting up a telemetry provider (like Sentry), which also needs to be done (1) early and (2) at the node.js side.
I agree and I would even say that a good sample is always minimal in general. While it can be more complex in the topic that it demonstrates, everything aound that is unrelated must be as minimal as possible and should not use any other patterns - which might be elegant and useful - but they never are for the one who is interested in the topic of the sample - such things are just a distraction.
It's much better to have many samples, each of which demonstrating one specific featuie or usage, than a huge all-in-one sample where a new user would have no clue where one feature ends and another one starts in the code.
@niteshsinghal85 - if you'd like to do a bit more, I'd have ideas for a number of other interesting samples:
e.g. for setting up IPC messaging between web content and .net ap
like
beforePack,afterPack,artifactBuildStarted,artifactBuildCompletedThis allows for example to manipulate or replace the
*.desktopfile for Linux appsThat's something you can hardly find anywhere...
How you can have a base project with Electron.NET code that is shared by multiple Electron.NET apps
A sample project, showing just ElectronHostHook without any distractions
A working sample with icons for all 3 platforms (Win, Linux, Mac)
(for most of them, I can provide something based on which a sample can be created)