#need to use react js I’m electron app - wanna know the right way for production

16 messages · Page 1 of 1 (latest)

manic mulch
#

I’m having trouble with integrating react to electron! I wanna know the right way to do it. As it has to go into production

i have tried just initializing an app

npm init and add amain.js and index.html, and when the basic electron is up and running, the added an src for react files and a webpack.config

basically followed a youtube video

and i also tried
making a react app with cra first and using concurrently and wait on to render in electron app which didn't seem like a good approach (I want to build this app for production later on)
this second approach didn't work for me btw

now im trying out
using npm init electron-app@latest my-new-app -- --template=webpack
and edit the webpack.config to accept6 jsx and react

solar jolt
#

Look at some react electron starters on github

#

Might give you an insight on what needs to be added/modified to make it work

#

You will most likely get the benefit of using vite this way too

south drum
#

So you tried with three different methods? Why not just try to make one of them works?

manic mulch
#

I’m not sure which is the correct way to make it work as I develop in react😅. (A bit new to electron)

south drum
#

all of them could work

manic mulch
#

Oh okay! Thanks I’ll continue with the whichever works in that case

#

Also, would it be any problem if I didn’t use CRA? For the react code in this?

south drum
#

No it's not a problem, but you will have to configure webpack yourself

#

or you can also try out Vite

manic mulch
#

Oh okay, thanks:)

manic mulch
#

Can I please know the use of Vite to build the electron soo with react?

south drum
#

Vite is to bundle your files

#

to build an Electron app (regardless of what you use for the renderer), you can use electron-forge or electron-builder

manic mulch
#

Great!! Thanks:)