livestorejs/livestore
View on GitHubLivestore fails to load in private browsing on Firefox
Open
#533 opened on Jul 31, 2025
adapter:webhelp wanted
Repository metrics
- Stars
- (3,599 stars)
- PR merge metrics
- (PR metrics pending)
Description
Repro (per title):
- Open firefox in private browsing mode (aka incognito)
- Attempt to run livestore
Actual error:
Uncaught (in promise) DOMException: Security error when calling GetDirectory opfs-utils.ts:18
It looks like getDirectory is not allowed, and needs to be handled. Relevant MDN docs: https://developer.mozilla.org/en-US/docs/Web/API/StorageManager/getDirectory
SecurityError DOMException Thrown if the browser is not able to map the requested directory to the local OPFS, for example due to storage or memory > constraints. Also thrown in some browsers if getDirectory() is called in private browsing mode.
Relevant livestore snippet
// To improve LiveStore compatibility with e.g. Node.js we're guarding for `navigator` / `navigator.storage` to be defined.
export const rootHandlePromise =
typeof navigator === 'undefined' || navigator.storage === undefined
? // We're using a proxy here to make the promise reject lazy
(new Proxy(
{},
{
get: () =>
Promise.reject(
new Error(`Can't get OPFS root handle in this environment as navigator.storage is undefined`),
),
},
) as never)
: navigator.storage.getDirectory()