Shared storage
Shared Storage API の SharedStorage インターフェイスは、特定のオリジンに対する共有ストレージを表し、共有ストレージにデータを書き込むためのメソッドを定義します。
SharedStorage は以下の基底クラスです。
* WindowSharedStorage。Window.sharedStorage 経由でアクセスされます。 * WorkletSharedStorage。SharedStorageWorkletGlobalScope.sharedStorage 経由でアクセスされます。
対応ブラウザ
| 機能 | デスクトップ | モバイル | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
SharedStorage 非推奨 | 126 | 126 | | | 126 | |
sharedStorageWritable 非推奨 | 126 | 126 | | | 126 | |
sharedStorageWritable 非推奨 | 126 | 126 | | | 126 | |
append 非推奨 SharedStorage インターフェイスの append() メソッドは、現在のオリジンの共有ストレージ内の既存のキーと値のペアの値に文字列を追加します。 | 126 | 126 | | | 126 | |
clear 非推奨 SharedStorage インターフェイスの clear() メソッドは、現在のオリジンの共有ストレージをクリアし、そこからすべてのデータを削除します。 | 126 | 126 | | | 126 | |
createWorklet 非推奨 | 126 | 126 | | | 126 | |
delete 非推奨 SharedStorage インターフェイスの delete() メソッドは、現在のオリジンの共有ストレージから既存のキーと値のペアを削除します。 | 126 | 126 | | | 126 | |
get 非推奨 | 126 | 126 | | | 126 | |
run 非推奨 | 126 | 126 | | | 126 | |
selectURL 非推奨 | 126 | 126 | | | 126 | |
set 非推奨 SharedStorage インターフェイスの set() メソッドは、現在のオリジンの共有ストレージに新しいキーと値のペアを保存するか、既存のキーと値のペアを更新します。 | 126 | 126 | | | 126 | |
worklet 非推奨 | 126 | 126 | | | 126 | |
| Shared Storage API の SharedStorageWorklet インターフェイスは、現在のオリジンの共有ストレージ ワークレットを表します。 | 126 | 126 | | | 126 | |
run 非推奨 | 126 | 126 | | | 126 | |
selectURL 非推奨 | 126 | 126 | | | 126 | |
| Shared Storage API の SharedStorageWorkletGlobalScope インターフェイスは、SharedStorageWorklet モジュールのグローバル スコープを表します。 | 126 | 126 | | | 126 | |
register 非推奨 SharedStorageWorkletGlobalScope インターフェイスの register() メソッドは、現在のワークレット モジュール内で定義された SharedStorageOperation を登録します。 | 126 | 126 | | | 126 | |
sharedStorage 非推奨 SharedStorageWorkletGlobalScope インターフェイスのコンテキスト読み取り専用プロパティには、ワークレット コンテキストに公開される特定のオリジンの共有ストレージを表す WorkletSharedStorage オブジェクト インスタンスが含まれています。 | 126 | 126 | | | 126 | |
sharedStorage 非推奨 グローバル読み取り専用のsharedStorageプロパティは、現在のオリジンのWindowSharedStorageオブジェクトを返します。 これは、共有ストレージ API を使用して共有ストレージにデータを書き込むためのメイン エントリ ポイントです。 | 126 | 126 | | | 126 | |
基本構文
window.sharedStorage
.set("ab-testing-group", "0")
.then(() => console.log("Value saved to shared storage")); 実務での使いどころ
-
Shared storage の活用
Shared Storage API の SharedStorage インターフェイスは、特定のオリジンに対する共有ストレージを表し、共有ストレージにデータを書き込むためのメソッドを定義します。
注意点
- 一部のブラウザでのみ対応。使用前にブラウザサポートを確認すること。
実装メモ
- 一部の API はセキュアコンテキスト (HTTPS) やユーザー操作起点を必要とする。利用前に要件を確認すること。