Are next.js or gatsby valid options for firebase reactjs projects?

I've always used CRA because of what I've felt like is limited benefit of static site generation or server rendering for a site that depends so heavily (as mine usually do) on rendering content from firebase data, and the modified rendering from subsequently modified data.

I've not tried either of these projects and am kind of too busy/lazy right now to check it out for myself. So my question to people who's tried it.. if you create a site heavily dependent on RTDB and firestore, is gatsby or nextjs realistic and helpful alternatives to create-react-app?

Posted Mar 3, 2019, 11:19 PM UTC

44
TomEnom•

The new next.js (v8 I think) lists 'serverless' amongst it's new features:

https://nextjs.org/blog/next-8/#serverless-nextjs

So, though it talks more about AWS Lambda, it presumably could be made to work with Firebase Functions.

2
boon4376•

I do not use CRA - I hate it and get downvoted a lot when I say that :-p

So far, I have not figured out why someone would want to use Gatsby or Next.js because I've never needed it.

I have a SSR rendered reactjs app (I don't use gatsby or next.js - just a react / redux / react router setup). Server-side before initial render, I have firebase functions that run and retrieve data from firestore (using the admin SDK), and then uses that data to provide an initial state that is rendered on the client-side.

It's very fast, the express app function can be cached for even greater speed (essentially making repeat requests load static cached content almost instantly), it's search engine optimized, and creates a seamless experience for the end-user.

If I needed more content management, I'd hookup a headless / decoupled install of Drupal or WordPress and use a firebase function to retrieve content from that server-side, before rendering client side, displaying the content with my own react components. Again, because repeat requests would be cached by the firebase function, it would have all the advantages speed-wise of a static site generator, but with more cache expiration / time control for frequently updated content in the CMS or firestore (no need to re-generate any static files).

1
ECrispy•

Your clearly experienced and know your way around these tools. The starter kits serve a useful purpose esp for people who are new but are also used in production by many.

You are clearly not the intended audience, but what do you have against CRA?

5
JosephAWalker•

In theory, it should work.

In practice, a few months ago I tried adding firebase to a Gatsby.js application and the build failed because the firebase library tried to do something to window (which doesn't exist at build time for Gatsby). I wasn't set on using firebase, so I quickly threw in the towel after 15 minutes of trying to get it to work. This may have been fixed at this point.

1
devPadre•

Both work well - I have firestore and gatsby at HappyGoLukky and firestore and NextJS at Candidit ... nice thing about the happygolukky site is it's also hosted on firebase for free.

1