Simple example of Chrome extension (with manifest v3) using Rust compiled to Wasm
Install wasm-pack:
cargo install wasm-pack
Go to /wasm_mod
and run build.bat
.
It will compile the .wasm
module and .js
-wrapper for it and put them in the extension/js/wasm
Go to Chrome extensions page and load unpacked extension from /extension
extension/js/content.js
demonstrates how to load wasm into the content script extension/js/background.js
demonstrates how to load wasm into the background worker scriptwasm-pack
always use --target web
manifest.json
:
.wasm
and corresponding .js
in the web_accessible_resources.resources
section of manifestwasm-unsafe-eval
in the content_security_policy.extension_pages
section of manifest