?
auth.getCurrentVisitorId
The stable anonymous visitor id for the current browser, or null before the session resolves.
auth.getCurrentVisitorId() → string | null
Returns a stable id for the current browser, even when nobody is signed in, or null before the session has resolved. It's the anonymous counterpart to a user id: key realtime channels on it for signed-out visitors, so user:null doesn't collapse every anonymous client onto one shared channel. Once a visitor signs in, switch to their user id.
Key a realtime channel for a signed-out visitor
const visitorId = auth.getCurrentVisitorId(); const channel = auth.currentUser ? `user:${auth.currentUser.id}` : `visitor:${visitorId}`;