Create your first extension
Build your first browser extension end-to-end with a practical workflow. Create a GitHub search shortcut that runs from the browser omnibox and learn the core Extension.js loop.
What you will build
The plan
Make GitHub search as fast as a native browser shortcut. The extension reserves the keyword gh; after the user types gh and a query, it opens GitHub search results.
The interface that we are creating here.
Step 1 - create the extension
Use the Extension.js create command to bootstrap a minimal extension named github-search.
Step 2 - create the manifest file
Step 2 Demo
Every extension starts with a manifest file. It defines metadata, permissions, and runtime files. Based on the plan above, we will set the gh shortcut and add a service worker for user events.
omnibox.keyword: When the keywordghis set, an event will be fired.background.service_worker: Will listen to the event that we just fired.
Step 3 - create the background service worker
In browser extensions, the background service worker handles browser events.
For this example, add a script that listens to omnibox input and routes the query to GitHub search.
Create service_worker.js:
The script above will open a new tab with GitHub search results whenever you enter something after "gh" in the URL bar.
Step 4 - load your extension
If you take a look at your package.json file now, it looks more or less like this:
These scripts are the default Extension.js commands. Run the extension for the first time:
If everything is configured correctly, you should see the following:
That's it! You created your first browser extension that searches on GitHub!
Step 5 - making it better
Improve the search experience by adding suggestions directly in the URL bar with an omnibox input listener.
Update service_worker.js to fetch GitHub suggestions and display them while typing.
This code adds live GitHub suggestions directly in the URL bar.
You now have a working GitHub search extension. Iterate on it and adapt it to your own workflow.
Next steps
- Create another extension with templates.
- Add automated checks with Playwright E2E.
- Review Troubleshooting, Security checklist, and Performance playbook as your extension grows.
