Is it a good idea to wrap a website in an Electron app window?

I've been trying to get a working beta of my moderation platform in an Electron app for a while now. Lately, I've been having issues regarding getting authentication to work within an Electron app using anywhere from React/Vite to Next or even Vue/Vite. I've done a ton of searches on Stack Overflow and Google and even looked at some tutorials on Auth0 (Okta) and on YouTube to try and gain a more deeper understanding of implementing authentication into Electron using a SPA framework. My authentication flow is not unique in the sense where I need to use a specific tool or protocol for it, seeing as I only need to authenticate users via Discord, but going through 10 testing codebases for one Electron app has slowed down my development significantly. I'm not looking for a spoon feed on exactly what stack or service to implement, more so some guidance on how I can overcome this issue, or a "hotfix" so I am able to use my authentication to test other code in my app like data fetching and whatnot. With that in mind, is using Electron as a "wrapper" of sorts the best way to go around this issue, and host the codebase as a website on something like Vercel? That way I have access to Server Components and data-fetching, and my authentication flow can also work - or is there some other path I can take to tackle this issue?
3 Replies
Iceorcus
Iceorcus2w ago
I was doing research on using Electron's in-built IPC handler, but I'm not sure if an IPC would be a good use case for something like authentication.
EntranceJew
EntranceJew6d ago
i found electron's IPC for talking between different layers of the app to be very restrictive and a little confusing to develop for. maybe if you have experience developing web-extensions then the messaging API is familiar and it won't throw you off that much. coincidentally I also implemented Discord.js within electron, and due to it being a bot context, had it even further removed from the thread it was spawned from due to the way the bot processs siolos off a single file of code (IPC also made this much more difficult to design for) I don't think you need to resort to IPC to authenticate with Discord, and access to their IPC API is severely limited and basically people can't even apply for it anymore so if it requires users getting it from discord directly then they can't. I think a typical OAuth flow should be all you need to auth with discord? https://discordjs.guide/oauth2/#authorization-code-grant-flow Apologies if I misunderstood anything.
Iceorcus
Iceorcus6d ago
I might try something like that, I’ve just been having issues trying to get something working authentication wise as doing things like API routes or server side rendering isn’t possible in Electon with frameworks like Next.js unless you work around it with a lot of tinkering.