Static Site Generation
Static Site Generation is exactly what it says on the tin – it’s the generating of static html files to serve to your end user. In the case of gatsby this means your react components are built into simple html files. This is great for sites where the content rarely changes as it is much faster to have pre-built html files waiting for a user to request them.
This approach is also not feasible if you have dynamic content on your site; eg a social network or any other site that relies on user generated content. Fortunately there is another option
Server Side Rendering
Server Side Rendering achieves the same end result of SSG but the way it arrives at this result is vastly different. When a site is built using SSR there are no html files waiting for a user – they must be generated per request. This means that the content served is guaranteed to be the latest without any long build processes. However, as the server has to build the template once the end user has requested it, the response times are noticeably slower.
Server Side Rendering is also arguably more complex to setup as it requires a node process running on your server. This initial setup complexity could be justified if you are expecting to make changes to content regularly as there are no additional steps; save your content change in your CMS and that’s it.
Overall both of these approaches are a great way to develop a site that has great SEO capabilities, as well as the greater UX of a single page app. For me there’s no real issue with either approach and deciding which is best for you purely comes down to the type of site.
If you have dynamic content or content that is updated frequently then spending a bit longer setting up SSR is definitely worth the investment.
However, if like most sites, your content will change rarely and you just wanted a nicer experience for your end user then go for SSG.