'React+Electron: Building web & desktop app at the same time with different behaviour

I need to build a website using React and a desktop app for a university project.

They are supposed to have very simillar functionality, so I thought about using Electron.

The main difference is that when using electron I need to have a "download" button in some areas, and a few other webpages ("my downloads" and "upload a file").

  1. Is it possible to easiliy share the frontend code between them,without copying the react code from one to the other each time it is updated?

  2. I thought about having in my React code something akin to

if (running on electron)
    displayAdditionalPages()

if (running on electron)
    fetchDownloadsProgress()

but couldn't find how to do it. Is it possible?

Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source