Electron Forge
  • Getting Started
  • Importing an Existing Project
  • CLI
  • Core Concepts
    • Why Electron Forge?
    • Build Lifecycle
  • Configuration
    • Configuration Overview
    • TypeScript Setup
    • Plugins
      • Webpack Plugin
      • Vite Plugin
      • Electronegativity Plugin
      • Auto Unpack Native Modules Plugin
      • Local Electron Plugin
      • Fuses Plugin
    • Makers
      • AppX
      • deb
      • DMG
      • Flatpak
      • pkg
      • RPM
      • Snapcraft
      • Squirrel.Windows
      • WiX MSI
      • ZIP
    • Publishers
      • Bitbucket
      • Electron Release Server
      • Google Cloud Storage
      • Nucleus
      • S3
      • Snapcraft
    • Hooks
  • Built-in Templates
    • Webpack
    • Webpack + Typescript
    • Vite
    • Vite + TypeScript
  • Guides
    • Code Signing
      • Signing a Windows app
      • Signing a macOS app
    • Custom App Icons
    • Framework Integration
      • React
      • React with TypeScript
      • Vue 3
    • Developing with WSL
  • Advanced
    • Auto Update
    • Debugging
    • Extending Electron Forge
      • Writing Plugins
      • Writing Templates
      • Writing Makers
      • Writing Publishers
    • API Docs
Powered by GitBook
On this page
  • Create the app and setup the TypeScript config
  • Add the React dependencies
  • Integrate React code

Was this helpful?

Edit on
  1. Guides
  2. Framework Integration

React with TypeScript

How to create an Electron app with React, TypeScript, and Electron Forge

PreviousReactNextVue 3

Last updated 1 year ago

Was this helpful?

Adding React support to the TypeScript + Webpack template is fairly straightforward and doesn't require a complicated boilerplate to get started.

The following guide has been tested with React 18, TypeScript 4.3, and Webpack 5.

Create the app and setup the TypeScript config

Create the app with the, then edit the newly created tsconfig.json to add the key-value entryto the "compilerOptions" section.

Add the React dependencies

Add the basic React packages to your dependencies and the corresponding types to your devDependencies:

npm install --save react react-dom
npm install --save-dev @types/react @types/react-dom

Integrate React code

You should now be able to start writing and using React components in your Electron app. The following is a very minimal example of how to start to add React code:

import { createRoot } from 'react-dom/client';

const root = createRoot(document.body);
root.render(<h2>Hello from React!</h2>);
// Add this to the end of the existing file
import './app';

For more about React, see.

TypeScript + Webpack template
"jsx": "react-jsx"
their documentation