Persisting local collections across browser tabs/windows

Hello there,

I am working on a Meteor app that stores some data in a local collection. Somewhere in my app, I want to provide the possibility to open a new browser tab/window and display the data currently stored in this local collection. Only, it seems that local collections are not persistent across browser tabs/windows! Whenever I check the local collection in the newly opened tab, it appears to be empty, and stays that way even when I add contents to the collection in the original tab.

Is there a way to let this local collection persist between browser tabs/windows, and just as important, remain being reactive (so if I add something in one tab, it will also appear in the other)?

I have already done some searching and it appears that using the browser’s localStorage (using jeffm:local-persist or frozeman:persistent-minimongo2 ) can be a solution. Is this really necessary, or is this overkill for what I am trying to achieve?

It’s really straightforward to use localStorage, so that’s definitely a valid option.

The only gotcha is Private Browsing mode in browsers, where the browser either can’t access localStorage or the data is not really persisted.

Also, as a heads up, in Private Browsing -mode Safari will claim that localStorage is available, but when trying to access the storage it will throw an error,… so remember to handle that. Other browsers handle this situation slightly better, if I remember correctly, by simply wiping out the data after the user closes the browser.

I use localStorage to save UI related state that the user probably wants to persist, but don’t really justify setting up Mongo Collections, publications, subscriptions etc…

Thanks for the advise. I went with frozeman:persistent-minimongo and it seems to do the job nicely. Behind the scenes it indeed uses localStorage. It’s fine if my app doesn’t work in private browsing mode for now. I’m used to this mode throwing up barriers that need some extra thought. That’s something to (possibly) worry about later.