{"id":20797184,"url":"https://github.com/daniguardiola/browser-namespace","last_synced_at":"2025-10-10T08:14:44.523Z","repository":{"id":212162642,"uuid":"730791846","full_name":"DaniGuardiola/browser-namespace","owner":"DaniGuardiola","description":"Cross-browser support for the \"browser\" namespace in browser extensions. Fully typed.","archived":false,"fork":false,"pushed_at":"2024-02-28T22:52:34.000Z","size":486,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T08:14:43.888Z","etag":null,"topics":["browser-extensions","chrome","chrome-extensions","javascript","typescript","web-extensions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DaniGuardiola.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-12T17:21:39.000Z","updated_at":"2023-12-23T12:47:55.000Z","dependencies_parsed_at":"2023-12-12T21:31:46.333Z","dependency_job_id":"b8f9f08f-dedc-43c6-984c-52ba65125dc5","html_url":"https://github.com/DaniGuardiola/browser-namespace","commit_stats":null,"previous_names":["daniguardiola/browser-namespace"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/DaniGuardiola/browser-namespace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaniGuardiola%2Fbrowser-namespace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaniGuardiola%2Fbrowser-namespace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaniGuardiola%2Fbrowser-namespace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaniGuardiola%2Fbrowser-namespace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DaniGuardiola","download_url":"https://codeload.github.com/DaniGuardiola/browser-namespace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaniGuardiola%2Fbrowser-namespace/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003301,"owners_count":26083555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser-extensions","chrome","chrome-extensions","javascript","typescript","web-extensions"],"created_at":"2024-11-17T16:32:53.693Z","updated_at":"2025-10-10T08:14:44.509Z","avatar_url":"https://github.com/DaniGuardiola.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# browser-namespace\n\nCross-browser support for the `browser` namespace in browser extensions. Fully typed.\n\n```bash\nnpm i browser-namespace\n```\n\n```ts\nimport { browser } from \"browser-namespace\";\n\nawait browser.storage.local.set(data); // for example\n```\n\n## What this package is\n\nSome browsers use the `browser` API namespace, while others use `chrome`. This package unifies both and provides a fully typed API.\n\nIt essentially does this:\n\n```ts\nexport const browser: BrowserAPI = window.browser ?? window.chrome;\n```\n\nThe types come from [`@types/webextension-polyfill`](https://www.npmjs.com/package/@types/webextension-polyfill).\n\n## What this package is not\n\nIn contrast with [webextension-polyfill](https://github.com/mozilla/webextension-polyfill), which does a lot more, this package limits itself to providing a convenient, unified and fully typed namespace.\n\nSupport for specific features still depends on the browser and version. For this reason, types might be inaccurate. Performing feature detection is recommended.\n\n## Chrome-specific namespace\n\nIf you need any Chrome-specific APIs, you can use the `chrome` namespace:\n\n```ts\nimport { chrome } from \"browser-namespace\";\n\nawait chrome.debugger.sendCommand(/* ... */); // for example\n```\n\nThe types are derived from [`@types/chrome`](https://www.npmjs.com/package/@types/chrome). The reason these types are copied instead of imported is because they declare `chrome` as a global variable, which might be unwanted. The version in this repo is patched to fix that.\n\nAgain, support for specific features depends on the browser and version.\n\n## Types\n\nThe types for both browser and Chrome API namespaces can be imported directly.\n\nThere are types for the APIs themselves (corresponding to the types of the `browser` and `chrome` runtime objects):\n\n```ts\nimport type { BrowserAPI, ChromeAPI } from \"browser-namespace\";\n```\n\nAdditionally, the TypeScript namespace declarations are also exported:\n\n```ts\nimport type { Browser, Chrome } from \"browser-namespace\";\n```\n\nThese are useful to access certain types. Some examples:\n\n- `Browser.Runtime.Port`, returned from `browser.runtime.connect`.\n- `Chrome.debugger.Debuggee`, passed to `chrome.debugger.attach`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniguardiola%2Fbrowser-namespace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaniguardiola%2Fbrowser-namespace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniguardiola%2Fbrowser-namespace/lists"}