From the project directory:
gcc -o hostapp host.c
chmod +x hostapp- Open Chrome and go to
chrome://extensions - Enable Developer mode (toggle in the top right)
- Find your extension — the ID is the 32-character string shown below the extension name
⚠️ If your extension is loaded unpacked without a fixedkeyin itsmanifest.json, the ID changes every time you reload it. To pin it, add akeyfield — see Chrome docs.
Create a file named com.ext.nattest.json (must match the name field exactly):
{
"name": "com.ext.nattest",
"description": "Native Messaging Host",
"path": "/absolute/path/to/your/hostapp",
"type": "stdio",
"allowed_origins": [
"chrome-extension://YOUR_EXTENSION_ID_HERE/"
]
}
⚠️ pathmust be absolute. Chrome does not expand~or relative paths. Use the full path, e.g./Users/yourname/nativemessaging/hostapp.
Copy the manifest to the directory Chrome scans at launch:
cp com.ext.nattest.json \
~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/| Browser | Path |
|---|---|
| Chrome (macOS) | ~/Library/Application Support/Google/Chrome/NativeMessagingHosts/ |
| Chrome Canary (macOS) | ~/Library/Application Support/Google/Chrome Canary/NativeMessagingHosts/ |
| Chromium (macOS) | ~/Library/Application Support/Chromium/NativeMessagingHosts/ |
| Chrome (Linux) | ~/.config/google-chrome/NativeMessagingHosts/ |
| Chrome (Windows) | Registry key under HKCU\Software\Google\Chrome\NativeMessagingHosts\ |