IjzerenHein / firestorter

Use Google Firestore in React with zero effort, using MobX 🤘
http://firestorter.com
MIT License
378 stars 50 forks source link

Nextjs SSR example #46

Open sne11ius opened 5 years ago

sne11ius commented 5 years ago

This is not a real "issue", but rather a suggestion: a minimal example of how to use firestorter with nextjs and SSR would be awesome ;)

IjzerenHein commented 5 years ago

Great idea. It's not on my prio list at the moment, so contributions would be very helpful for this. Cheers!

RWOverdijk commented 4 years ago

Did either of you happen to do this yet? I'm trying to get it working now and... Well, let's just say it's not.

firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error: firestorter: cannot get firestore: Error:....

etc.

RWOverdijk commented 4 years ago

Looking into this, I think that perhaps firestorter or even mobx wouldn't make sense with next.js.

I found this article which explains how you could use mobx in next, but it feels clunky to me.

Zeit's swr seems capable of listeners and such as well. Working with small functional components with swr should yield the same result as working with firestorter and mobx.

By this I mean that you could set up a new onSnapshot listener on a collection/document and use swr's mutate to maintain it locally (so, use Mode.On basically).

To make it "smart" it'd have to be an effect with counters to check if anyone is observing though, so something could be done there.

But if all that is needed is a check to see if anyone is listening to the data I wouldn't use mobx for that. It's a pretty large library for something that could be solved with useEffect. The obvious downside is that you basically have to use hook. But that doesn't seem avoidable anymore anyway so... Why not.

I hope my ramblings help anyone. If not, well, at least I got to ramble.

thirdman commented 3 years ago

I'm also getting the Error: firestorter: cannot get firestore: Error: firest... issue with next.js, so just arrived here from google. :D I'm not sure where to init, since I'm basically recreating an app that works in firebase hosting.

Just want to say I enjoyed your ramble.