{"id":30882383,"url":"https://github.com/try0/browser-tab-id","last_synced_at":"2026-01-20T17:32:24.834Z","repository":{"id":310021711,"uuid":"1038031253","full_name":"try0/browser-tab-id","owner":"try0","description":"@try0/browser-tab-id generates IDs, stores them in sessionStorage, and helps minimize duplicates across tabs./IDを生成し、なるべく重複しないようsessionStorageで管理する","archived":false,"fork":false,"pushed_at":"2025-08-31T00:22:38.000Z","size":106,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-31T02:30:46.798Z","etag":null,"topics":["browser-tab","browser-tab-id","id","id-generator","session"],"latest_commit_sha":null,"homepage":"https://try0.github.io/browser-tab-id/","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/try0.png","metadata":{"files":{"readme":"README.ja.md","changelog":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-14T14:04:50.000Z","updated_at":"2025-08-31T00:22:41.000Z","dependencies_parsed_at":"2025-08-23T15:34:05.106Z","dependency_job_id":null,"html_url":"https://github.com/try0/browser-tab-id","commit_stats":null,"previous_names":["try0/browser-tab-id"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/try0/browser-tab-id","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/try0%2Fbrowser-tab-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/try0%2Fbrowser-tab-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/try0%2Fbrowser-tab-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/try0%2Fbrowser-tab-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/try0","download_url":"https://codeload.github.com/try0/browser-tab-id/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/try0%2Fbrowser-tab-id/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274159640,"owners_count":25232636,"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-09-08T02:00:09.813Z","response_time":121,"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-tab","browser-tab-id","id","id-generator","session"],"created_at":"2025-09-08T08:47:21.127Z","updated_at":"2026-01-20T17:32:24.797Z","avatar_url":"https://github.com/try0.png","language":"TypeScript","readme":"# browser-tab-id\n\n[English](./README.md) | [日本語](./README.ja.md)\n\n時間 + ランダム数字 + インクリメント でIDを生成して、タブ間でなるべく重複しないようsessionStorageで管理します。  \n\n\n```\n{timestamp}_{random}_{counter}\n1755313540998_87226662_0001\n```\n\n* インクリメント部は、[Web Locks API](https://developer.mozilla.org/ja/docs/Web/API/Web_Locks_API)が使える環境であれば、ロックを取得してインクリメント。\n* window.openerがあれば、sessionStorageを直接確認。\n* 別タブとイベントやり取りで重複チェック。\n\n\n## Usage\n\n[npm](https://www.npmjs.com/package/@try0/browser-tab-id)\n```\nnpm i @try0/browser-tab-id\n```\n\n最小構成\n```JS\nconst tabId = await BrowserTabId.initialize();\n```\n\n全オプション\n```JS\nconst tabId = await BrowserTabId.initialize({\n    tabIdKey: \"btid\", // sessionStorageのキー。他プレフィックスとして使用。\n    randomDigits: 8, // ランダム数値部桁数。0で省略。\n    duplicateCheckWaitTime: 600, // 他タブへの重複チェックにかける待機時間ミリ秒。\n    cycleCounterDigits: 4, // インクリメント数値部桁数。0で省略。桁超えると最初に戻る。\n    cycleCounterType: \"indexed-db\", // リングカウンターの記録ストア。 or local-storage。indexed-db使用不可時はlocal-storageへフォールバック。\n    channels: [\"broadcast-channel\", \"local-storage\"], // 他タブへの問い合わせ方法。broadcast-channel使用不可時はlocal-storageへフォールバック。\n    decorate: (idSrc) =\u003e [idSrc.timestampString, idSrc.randomString, idSrc.cycleCountString].join(\"_\"), // フォーマットの変更。ランダム・カウンター部は0埋めの文字列。\n    debugLog: false, // デバッグ用ログ。\n});\n```\n\nTypeScript\n```ts\nimport BrowserTabId , { type BrowserTabIdOption, type TabIdStringSource } from '@try0/browser-tab-id'\n\nconst btOption: BrowserTabIdOption = {\n\n}\nconst tabId: string = await BrowserTabId.initialize(btOption);\n\n```\n\n既存のID生成ロジックへの移譲\n```JS\nconst tabId = await BrowserTabId.initialize({\n     decorate: (idSrc) =\u003e ulid()\n});\n```\n\nCDNから直\n```\n\u003cscript src=\"https://unpkg.com/@try0/browser-tab-id@0.0.4/dist/browser-tab-id.umd.js\"\u003e\u003c/script\u003e\n```\n```\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/@try0/browser-tab-id@0.0.4/dist/browser-tab-id.umd.js\"\u003e\u003c/script\u003e\n```\n\n\n## デモ\n\n[Sample](https://try0.github.io/browser-tab-id/index.html)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftry0%2Fbrowser-tab-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftry0%2Fbrowser-tab-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftry0%2Fbrowser-tab-id/lists"}