<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ashish Srivastava on Medium]]></title>
        <description><![CDATA[Stories by Ashish Srivastava on Medium]]></description>
        <link>https://medium.com/@ashish.sri?source=rss-61824fc66fbb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*X35ux4DZCSYrWOqKwPcniw.jpeg</url>
            <title>Stories by Ashish Srivastava on Medium</title>
            <link>https://medium.com/@ashish.sri?source=rss-61824fc66fbb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 10:33:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ashish.sri/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Create a Desktop App Using Electron and React]]></title>
            <link>https://medium.com/bobble-engineering/create-a-desktop-app-using-electron-and-react-b23b435c0506?source=rss-61824fc66fbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b23b435c0506</guid>
            <category><![CDATA[electronjs]]></category>
            <category><![CDATA[desktop-app]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Ashish Srivastava]]></dc:creator>
            <pubDate>Fri, 28 Aug 2020 04:55:05 GMT</pubDate>
            <atom:updated>2020-08-28T04:55:05.503Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*kXUV23TqjRruaiRs-8wLRQ.png" /></figure><p><strong>A basic guide to start using Electron with React in minimum steps</strong></p><p>Electron says that if you can build a website, you can build a cross-platform desktop app. Our beloved code editor VS Code uses electron, so does Whatsapp Desktop App. Electron uses Node.js runtime and Chromium rendering engine to build apps using HTML, CSS and JavaScript.</p><h3>Why React</h3><p>React is an open-source JavaScript library for building user interfaces or UI components. Both functional(hooks) and class component approach is fun to learn. React is declarative and component based.</p><h3>Create-React-App</h3><p>To start building a new single page React application, React Community provides a boilerplate application to jump start app development.</p><blockquote>Note: Make sure you have Node.js installed in your system</blockquote><h3>Creating our React Application</h3><p>With your CLI pointing to the folder you want to store your app, run</p><pre><em>npx create-react-app electron-react-demo</em></pre><p>which creates a new react application named <em>electron-react-demo</em> with required boilerplates.</p><pre>cd electron-react-demo<br>npm start</pre><p>to start your React app on localhost.</p><blockquote>You can now view electron-react-demo in the browser. <br> Local: <a href="http://localhost:3000/">http://localhost:3000</a></blockquote><p>The folder structure of <em>electron-react-demo</em> will be:</p><blockquote>electron-react-demo <br>├── README.md <br>├── node_modules <br>├── package.json <br>├── .gitignore <br>├── public <br>│ ├── favicon.ico <br>│ ├── index.html <br>│ └── manifest.json <br>└── src <br> │├── App.css <br> │├── App.js <br> │├── App.test.js <br> │├── index.css <br> │├── index.js <br> │├── logo.svg <br> │├── serviceWorker.js <br> └── setupTests.js</blockquote><h3>Installing Electron</h3><p>We install Electron as a dev-dependency</p><pre>npm install -D electron</pre><p>In src folder we create a new file <em>electron.js</em> to launch the electron application</p><pre>const electron = require(&#39;electron&#39;);<br>const app = electron.app;<br>const BrowserWindow = electron.BrowserWindow;</pre><pre>let mainWindow;</pre><pre>function createWindow() {</pre><pre>mainWindow = new BrowserWindow({<br>        width: 1024, <br>        height: 768,<br>        webPreferences:{<br>            nodeIntegration:true<br>        }<br>    });</pre><pre>mainWindow.loadURL(&#39;<a href="http://localhost:3000&#39;">http://localhost:3000&#39;</a>);</pre><pre>mainWindow.webContents.openDevTools();</pre><pre>mainWindow.on(&#39;closed&#39;, function () {<br>        mainWindow = null<br>    })</pre><pre>}</pre><pre>app.on(&#39;ready&#39;, createWindow);</pre><pre>app.on(&#39;window-all-closed&#39;, function () {<br>    if (process.platform !== &#39;darwin&#39;) {<br>        app.quit()<br>    }<br>});</pre><pre>app.on(&#39;activate&#39;, function () {<br>    if (mainWindow === null) {<br>        createWindow()<br>    }<br>});</pre><p>Electron has two process: <br>1. Main process — <em>electron.js</em> launched on application start is the main process.<br>2. Renderer process — <em>BrowserWindows</em> created in main process can access the renderer APIs for UI and connectivity.</p><p>The <em>app</em> API is used to control the event lifecycle of the application and creates window on event <em>‘ready’</em>. <em>BrowserWindow</em> API is used to create and control browser windows. <em>createWindow</em> creates a new window with specified height and width and other relevant specifications. Open Chrome Developer tools using <em>openDevTools()</em>. Browser Window created listens for a <em>‘closed’</em> event to close the window. Browser Windows loads the localhost port on which the React app is running.</p><h3>Launching React Application in Electron</h3><ol><li><strong>Add an entry point to Electron</strong></li></ol><p>We add a main entry point in <em>package.json</em>, which holds all the metadata related to the project.</p><pre>&quot;main&quot;: &quot;src/electron.js&quot;</pre><p>Also, to run electron we add a run target to Electron in <em>package.json</em>,</p><pre>&quot;electron&quot;:&quot;electron .&quot;</pre><p>2. Running the below commands separately opens an Electron application with create-react-app content. We can make changes in <em>App.js</em> to edit the UI.</p><pre>npm start<br>npm run electron</pre><p>Here, we have created an Desktop application with minimum effort for development. <br>However, both React dev server and Electron must be launched separately and must be run in such a way that Electron is launched after React scripts are loaded.</p><p><strong>3. Using Foreman to simplify application launch</strong></p><p>Foreman is a process management tool, we add it using</p><pre>npm install -D foreman</pre><p>We create a <em>Procfile</em> to manage the launch of two process i.e. React webpack-dev-server and electron as:</p><pre>react:npm start<br>electron:npm run electron</pre><p>This solves our problem of separately launching the two processes. We add a new file named <em>wait-for-react.js</em> to deal with our issue waiting for React dev server to start and then launching electron.</p><pre>// wait-for-react.js<br>const net = require(&#39;net&#39;);<br>const port = process.env.PORT ? (process.env.PORT - 100) : 3000;</pre><pre>process.env.ELECTRON_START_URL = `<a href="http://localhost:${port}`">http://localhost:${port}`</a>;</pre><pre>const client = new net.Socket();</pre><pre>let startedElectron = false;<br>const tryConnection = () =&gt; client.connect({port: port}, () =&gt; {<br>        client.end();<br>        if(!startedElectron) {<br>            console.log(&#39;starting electron&#39;);<br>            startedElectron = true;<br>            const exec = require(&#39;child_process&#39;).exec;<br>            exec(&#39;npm run electron&#39;);<br>        }<br>    }<br>);</pre><pre>tryConnection();</pre><pre>client.on(&#39;error&#39;, (error) =&gt; {<br>    setTimeout(tryConnection, 1000);<br>});</pre><p>This simple node script checks if the React dev has started and then launches the electron process. We modify the earlier added <em>Procfile</em></p><pre>react:npm start<br>electron:npm run src/wait-for-react.js</pre><p><strong>4. Further, we make some changes to our <em>package.json</em> file:</strong></p><ol><li>Since, <em>create-react-app</em> builds an <em>index.html</em> that uses absolute paths by default. So, it fails to load it in Electron. However, there is a config option to change this, to set a homepage property in <em>package.json</em>. We set this property in current directory and <em>npm run build</em> will use this as a relative path.</li></ol><pre>&quot;homepage&quot;:&quot;./&quot;</pre><p>2. npm start should launch our application as desired. However, currently this only launches the React dev server. Therefore, we add the following changes to <em>package.json</em> and <em>Procfile</em> respectively,</p><pre>“start”: “nf start -p 3000”, <br>“electron-start”:”node src/wait-for-react”, <br>“react-start”:”react-scripts start”</pre><p>Final <em>Procfile,</em></p><pre>react: npm run react-start<br>electron: npm run electron-start</pre><p>These two complimentary changes, enables us to use npm startto launch the application. Also, we add a <em>.env</em> file with BROWSER=none in source directory to stop the React dev server to start in browser. Finally our <em>package.json</em> file is as</p><pre>{<br>  &quot;name&quot;: &quot;electron-react-demo&quot;,<br>  &quot;version&quot;: &quot;0.1.0&quot;,<br>  &quot;private&quot;: true,<br>  &quot;dependencies&quot;: {<br>    &quot;<a href="http://twitter.com/testing">@testing</a>-library/jest-dom&quot;: &quot;^4.2.4&quot;,<br>    &quot;<a href="http://twitter.com/testing">@testing</a>-library/react&quot;: &quot;^9.5.0&quot;,<br>    &quot;<a href="http://twitter.com/testing">@testing</a>-library/user-event&quot;: &quot;^7.2.1&quot;,<br>    &quot;react&quot;: &quot;^16.13.1&quot;,<br>    &quot;react-dom&quot;: &quot;^16.13.1&quot;,<br>    &quot;react-scripts&quot;: &quot;3.4.3&quot;<br>  },<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;:&quot;nf start -p 3000&quot;,<br>    &quot;react-start&quot;: &quot;react-scripts start&quot;,<br>    &quot;build&quot;: &quot;react-scripts build&quot;,<br>    &quot;test&quot;: &quot;react-scripts test&quot;,<br>    &quot;eject&quot;: &quot;react-scripts eject&quot;,<br>    &quot;electron&quot;: &quot;electron .&quot;<br>  },<br>  &quot;eslintConfig&quot;: {<br>    &quot;extends&quot;: &quot;react-app&quot;<br>  },<br>  &quot;browserslist&quot;: {<br>    &quot;production&quot;: [<br>      &quot;&gt;0.2%&quot;,<br>      &quot;not dead&quot;,<br>      &quot;not op_mini all&quot;<br>    ],<br>    &quot;development&quot;: [<br>      &quot;last 1 chrome version&quot;,<br>      &quot;last 1 firefox version&quot;,<br>      &quot;last 1 safari version&quot;<br>    ]<br>  },<br>  &quot;homepage&quot;:&quot;./&quot;,<br>  &quot;devDependencies&quot;: {<br>    &quot;electron&quot;: &quot;^10.0.0&quot;,<br>    &quot;foreman&quot;: &quot;^3.0.1&quot;<br>  },<br>  &quot;description&quot;: &quot;This is a project demonstrating create-react-app with electron.&quot;,<br>  &quot;main&quot;: &quot;src/electron.js&quot;,<br>  &quot;keywords&quot;: [<br>    &quot;electron&quot;,<br>    &quot;react&quot;<br>  ],<br>  &quot;author&quot;: &quot;*******@bobble.ai&quot;,<br>  &quot;license&quot;: &quot;ISC&quot;<br>}</pre><p>Now, run npm start and there, our electron app with React Front end is running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nJpR1hPxC5rkKuciNN-mHg.jpeg" /><figcaption>Our Electron Application with Dev Tools opened</figcaption></figure><p>To access the file system or to use the Electron’s <em>ipcRenderer, </em>we need to import Electron in the React app with the following workaround,</p><pre>const electron = window.require(&#39;electron&#39;);</pre><p>In development, an environment variable ELECTRON_START_URL can specify the URL for mainWindow.loadURL (in electron.js).</p><p>In production, if the env var exists we use it, else we load the static <em>index.html </em>file.</p><pre>const startUrl = process.env.ELECTRON_START_URL || url.format({<br>            pathname: path.join(__dirname, &#39;/../build/index.html&#39;),<br>            protocol: &#39;file:&#39;,<br>            slashes: true<br>        });<br>mainWindow.loadURL(startUrl);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*lbiNY7CUvz6uLzMXMNEj-A.jpeg" /><figcaption>Final directory structure</figcaption></figure><h3>Coming soon</h3><p>Electron packs a lot of APIs and has a lot to offer for developers e.g. creating frame-less Apps. Stay tuned for more exciting stories.</p><p>Thanks and Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b23b435c0506" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bobble-engineering/create-a-desktop-app-using-electron-and-react-b23b435c0506">Create a Desktop App Using Electron and React</a> was originally published in <a href="https://medium.com/bobble-engineering">Bobble Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Desktop App Using Electron and React]]></title>
            <link>https://medium.com/@ashish.sri/create-a-desktop-app-using-electron-and-react-6ab76e3935f2?source=rss-61824fc66fbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ab76e3935f2</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[electronjs]]></category>
            <category><![CDATA[desktop-app]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ashish Srivastava]]></dc:creator>
            <pubDate>Wed, 26 Aug 2020 12:56:12 GMT</pubDate>
            <atom:updated>2020-08-27T11:17:11.631Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*kXUV23TqjRruaiRs-8wLRQ.png" /></figure><p><strong>A basic guide to start using electron with React in minimum steps</strong></p><p>Electron says that if you can build a website, you can build a cross-platform desktop app. Our beloved code editor VS Code uses electron, so does Whatsapp Desktop App. Electron uses Node.js runtime and Chromium rendering engine to build apps using HTML, CSS and JavaScript.</p><h3>Why React</h3><p>React is an open-source JavaScript library for building user interfaces or UI components. Both functional(hooks) and class component approach is fun to learn. React is declarative and component based.</p><h3>Create-React-App</h3><p>To start building a new single page react application, React Community provides a boilerplate application to jump start app development.</p><blockquote>Note: Make sure you have Node.js installed in your system</blockquote><h3>Creating our React Application</h3><p>With your CLI pointing to the folder you want to store your app, run</p><pre><em>npx create-react-app electron-react-demo</em></pre><p>which creates a new react application named electron-react-demo with required boilerplates.</p><pre>cd electron-react-demo<br>npm start</pre><p>to start your React app on localhost.</p><blockquote>You can now view electron-react-demo in the browser. <br> Local: <a href="http://localhost:3000/">http://localhost:3000</a></blockquote><p>The folder structure of electron-react-demo will be:</p><blockquote>electron-react-demo <br>├── README.md <br>├── node_modules <br>├── package.json <br>├── .gitignore <br>├── public <br>│ ├── favicon.ico <br>│ ├── index.html <br>│ └── manifest.json <br>└── src <br> │├── App.css <br> │├── App.js <br> │├── App.test.js <br> │├── index.css <br> │├── index.js <br> │├── logo.svg <br> │├── serviceWorker.js <br> └── setupTests.js</blockquote><h3>Installing Electron</h3><p>We install electron as a dev-dependency</p><pre>npm install -D electron</pre><p>In src folder we create a new file <em>electron.js</em> to launch the electron application</p><pre>const electron = require(&#39;electron&#39;);<br>const app = electron.app;<br>const BrowserWindow = electron.BrowserWindow;</pre><pre>let mainWindow;</pre><pre>function createWindow() {</pre><pre>mainWindow = new BrowserWindow({<br>        width: 1024, <br>        height: 768,<br>        webPreferences:{<br>            nodeIntegration:true<br>        }<br>    });</pre><pre>mainWindow.loadURL(&#39;<a href="http://localhost:3000&#39;">http://localhost:3000&#39;</a>);</pre><pre>mainWindow.webContents.openDevTools();</pre><pre>mainWindow.on(&#39;closed&#39;, function () {<br>        mainWindow = null<br>    })</pre><pre>}</pre><pre>app.on(&#39;ready&#39;, createWindow);</pre><pre>app.on(&#39;window-all-closed&#39;, function () {<br>    if (process.platform !== &#39;darwin&#39;) {<br>        app.quit()<br>    }<br>});</pre><pre>app.on(&#39;activate&#39;, function () {<br>    if (mainWindow === null) {<br>        createWindow()<br>    }<br>});</pre><p>Electron has two process: <br>1. Main process — <em>electron.js</em> launched on application start is the main process.<br>2. Renderer process — <em>BrowserWindows</em> created in main process can access the renderer APIs for UI.</p><p>The <em>app</em> API is used to control the event lifecycle of the application and creates window on event <em>‘ready’</em>. <em>BrowserWindow</em> API is used to create and control browser windows. <em>createWindow</em> creates a new window with specified height and width and other relevant specifications. Open Chrome Developer tools using <em>openDevTools()</em>. Browser Window created listens for a <em>‘closed’</em> event to close the window. Browser Windows loads the localhost port on which the React app is running.</p><h3>Launching React Application in electron</h3><ol><li><strong>Add an entry point to electron</strong></li></ol><p>We add a main entry point in <em>package.json</em>, which holds all the metadata related to the project.</p><pre>&quot;main&quot;: &quot;src/electron.js&quot;</pre><p>Also, to run electron we add a run target to electron in <em>package.json</em>,</p><pre>&quot;electron&quot;:&quot;electron .&quot;</pre><p>2. Running the below commands separately opens an Electron application with create-react-app content. We can make changes in <em>App.js</em> to edit the UI.</p><pre>npm start<br>npm run electron</pre><p>Here, we have created an Desktop application with minimum effort for development. <br>However, both React dev server and Electron must be launched separately and must be run in such a way that Electron is launched after react scripts are loaded.</p><p><strong>3. Using Foreman to simplify application launch</strong></p><p>Foreman is a process management tool, we add it using</p><pre>npm install -D foreman</pre><p>We create a <em>Procfile</em> to manage the launch of two process i.e. React webpack-dev-server and electron as:</p><pre>react:npm start<br>electron:npm run electron</pre><p>This solves our problem of separately launching the two processes. We add a new file named <em>wait-for-react.js</em> to deal with our issue waiting for React dev server to start and then launching electron.</p><pre>// wait-for-react.js<br>const net = require(&#39;net&#39;);<br>const port = process.env.PORT ? (process.env.PORT - 100) : 3000;</pre><pre>process.env.ELECTRON_START_URL = `<a href="http://localhost:${port}`">http://localhost:${port}`</a>;</pre><pre>const client = new net.Socket();</pre><pre>let startedElectron = false;<br>const tryConnection = () =&gt; client.connect({port: port}, () =&gt; {<br>        client.end();<br>        if(!startedElectron) {<br>            console.log(&#39;starting electron&#39;);<br>            startedElectron = true;<br>            const exec = require(&#39;child_process&#39;).exec;<br>            exec(&#39;npm run electron&#39;);<br>        }<br>    }<br>);</pre><pre>tryConnection();</pre><pre>client.on(&#39;error&#39;, (error) =&gt; {<br>    setTimeout(tryConnection, 1000);<br>});</pre><p>This simple node script checks if the React dev has started and then launches the electron process. We modify the earlier added <em>Procfile</em></p><pre>react:npm start<br>electron:npm run src/wait-for-react.js</pre><p><strong>4. Further, we make some changes to our <em>package.json</em> file:</strong></p><ol><li>Since, <em>create-react-app</em> builds an <em>index.html</em> that uses absolute paths by default. So, it fails to load it in Electron. However, there is a config option to change this, to set a homepage property in <em>package.json</em>. We set this property in current directory and <em>npm run build</em> will use this as a relative path.</li></ol><pre>&quot;homepage&quot;:&quot;./&quot;</pre><p>2. <em>npm start</em> should launch our application as desired. However, currently this only launches the React dev server. Therefore, we add the following changes to <em>package.json</em> and <em>Procfile</em> respectively,</p><pre>“start”: “nf start -p 3000”, <br>“electron-start”:”node src/wait-for-react”, <br>“react-start”:”react-scripts start”</pre><p>Final <em>Procfile,</em></p><pre>react: npm run react-start<br>electron: npm run electron-start</pre><p>These two complimentary changes, make us use npm startto launch the application. Also, we add a <em>.env</em> file with BROWSER=none in source directory to stop the React dev server to start in browser. Finally our <em>package.json</em> file is as</p><pre>{<br>  &quot;name&quot;: &quot;electron-react-demo&quot;,<br>  &quot;version&quot;: &quot;0.1.0&quot;,<br>  &quot;private&quot;: true,<br>  &quot;dependencies&quot;: {<br>    &quot;<a href="http://twitter.com/testing">@testing</a>-library/jest-dom&quot;: &quot;^4.2.4&quot;,<br>    &quot;<a href="http://twitter.com/testing">@testing</a>-library/react&quot;: &quot;^9.5.0&quot;,<br>    &quot;<a href="http://twitter.com/testing">@testing</a>-library/user-event&quot;: &quot;^7.2.1&quot;,<br>    &quot;react&quot;: &quot;^16.13.1&quot;,<br>    &quot;react-dom&quot;: &quot;^16.13.1&quot;,<br>    &quot;react-scripts&quot;: &quot;3.4.3&quot;<br>  },<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;:&quot;nf start -p 3000&quot;,<br>    &quot;react-start&quot;: &quot;react-scripts start&quot;,<br>    &quot;build&quot;: &quot;react-scripts build&quot;,<br>    &quot;test&quot;: &quot;react-scripts test&quot;,<br>    &quot;eject&quot;: &quot;react-scripts eject&quot;,<br>    &quot;electron&quot;: &quot;electron .&quot;<br>  },<br>  &quot;eslintConfig&quot;: {<br>    &quot;extends&quot;: &quot;react-app&quot;<br>  },<br>  &quot;browserslist&quot;: {<br>    &quot;production&quot;: [<br>      &quot;&gt;0.2%&quot;,<br>      &quot;not dead&quot;,<br>      &quot;not op_mini all&quot;<br>    ],<br>    &quot;development&quot;: [<br>      &quot;last 1 chrome version&quot;,<br>      &quot;last 1 firefox version&quot;,<br>      &quot;last 1 safari version&quot;<br>    ]<br>  },<br>  &quot;homepage&quot;:&quot;./&quot;,<br>  &quot;devDependencies&quot;: {<br>    &quot;electron&quot;: &quot;^10.0.0&quot;,<br>    &quot;foreman&quot;: &quot;^3.0.1&quot;<br>  },<br>  &quot;description&quot;: &quot;This is a project demonstrating create-react-app with electron.&quot;,<br>  &quot;main&quot;: &quot;src/electron.js&quot;,<br>  &quot;keywords&quot;: [<br>    &quot;electron&quot;,<br>    &quot;react&quot;<br>  ],<br>  &quot;author&quot;: &quot;*******@bobble.ai&quot;,<br>  &quot;license&quot;: &quot;ISC&quot;<br>}</pre><p>Now, run npm start and there, our electron app with React Front end is running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nJpR1hPxC5rkKuciNN-mHg.jpeg" /><figcaption>Our Electron Application with Dev Tools opened</figcaption></figure><p>To access the file system or to use the Electron’s <em>ipcRenderer, </em>we need to import Electron in the React app with the following workaround,</p><pre>const electron = window.require(&#39;electron&#39;);</pre><p>In development, an environment variable ELECTRON_START_URL can specify the URL for mainWindow.loadURL (in electron.js).</p><p>In production, if the env var exists we use it, else we load the static <em>index.html </em>file.</p><pre>const startUrl = process.env.ELECTRON_START_URL || url.format({<br>            pathname: path.join(__dirname, &#39;/../build/index.html&#39;),<br>            protocol: &#39;file:&#39;,<br>            slashes: true<br>        });<br>mainWindow.loadURL(startUrl);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*lbiNY7CUvz6uLzMXMNEj-A.jpeg" /><figcaption>Final directory structure</figcaption></figure><h3>Coming soon</h3><p>Electron packs a lot of APIs and has a lot to offer for developers e.g. creating frame-less Apps. Stay tuned for more exciting stories.</p><p>Thanks and Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ab76e3935f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>