Skip to content

A minimal Electron + WebAssembly (WASM) + Rust project template (Updated April 2021)

Notifications You must be signed in to change notification settings

coderthetyler/electron-rust-quick-start

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

electron-rust-quick-start

A minimal Electron + Rust example.

🌈 About

This repo is intended to offer an understandable example of calling into Rust from Electron.

If you plan to use this as a starting point for your project, definitely update the package.json and Cargo.toml with your information.

This template was created by synthesizing information from the following:

✅ Prerequisites

⚡️ Getting started

Here's a one-liner:

git clone https://github.com/tylerdaddio/electron-rust-quick-start && cd electron-rust-quick-start && npm i && npm run wasm-build && npm start

And here's that one-linear broken into steps:

# Clone this repo
git clone https://github.com/tylerdaddio/electron-rust-quick-start

# Navigate into the folder
cd electron-rust-quick-start

# Download required npm packages listed in `package.json` (i.e. Electron & its dependencies)
npm install

# Build the sample `rust-lib` project into WebAssembly & JavaScript bindings. (See the full command in the `package.json`.)
npm run wasm-build

# Run the application. A window should open and an alert should appear.
npm start

✨ Tidbits

The Content-Security-Policy in the index.html is set to enable unsafe-eval. That seems unsafe. Why is that unsafe thing there?

Good question!

At time of writing, unsafe-eval is required in Chromium if you want to call into a WASM module. This shouldn't be required once wasm-eval is standardized, but only maybe (?).

As Electron is built on a web brower and has access to the full resources of your computer, it is severely unsafe by default. Before getting started, please perform the mandatory reading 📚.

🎓 Learn more

Here's some more stuff I've found helpful, inspiring, or both:

About

A minimal Electron + WebAssembly (WASM) + Rust project template (Updated April 2021)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published