Skip to content

Instantly share code, notes, and snippets.

@colorfield
Last active February 5, 2022 12:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colorfield/22b1a451d90b2a159c7d3d679197812f to your computer and use it in GitHub Desktop.
Save colorfield/22b1a451d90b2a159c7d3d679197812f to your computer and use it in GitHub Desktop.
Drupal, Gatsby and Next

Drupal, Gatsby and Next

  • Gatsby and Next are both based on React.
  • No technical details here, just some personal opinions and resources
  1. Why not just Drupal Twig an jQuery
  2. When to use a Drupal backend
  3. When to use a Drupal frontend
  4. React and Vue
  5. Gatsby and Next
  6. SSR (Server Side Rendering) and SSG (Static Site Generation)
  7. Integration of Gatsby with Drupal
  8. Learning resources

1. Why Gatsby or Next and not Drupal Twig

  • Fast by design while using SSG (Static Site Generator)
  • Secure by design: reduce the pressure of updating Drupal constantly (e.g. limit access by ip)
  • Possibility to outsource hosting to rather cheap platforms platform
    • Out of the box deployment pipeline
    • No server provisioning / maintenance / security issues
    • Most of them have CDN
    • Variety of providers (Gatsby Cloud, Vercel, Netlify, GitHub pages...)
  • Static generation is more than fast
    • Drupal frontend caching can be ignored: cache tags/contexts for invalidation can be quite complex depending on the use case (e.g. a site that has per region and language content)
    • Varnish is not needed
  • Better DX - jQuery in 2021 is not awesome when we have EcmaScript 6+ and TypeScript
  • Schema stitching when using multiple sources
  • React / Node stack is quite popular, larger developer base than Drupal so easier to hire devs
  • Drupal might not even be needed for smaller projects: Prismic, Sanity, Contenful, Cosmic, Wordpress, … some platforms are also providing their own CMS (e.g. Netlify)
  • How drupal can stay relevant compared to fully decoupled SaaS solutions with excellent DX?

2. When shall we use a Drupal backend (instead of any other decoupled CMS)?

  • Complex content model
  • Workflows / content moderation
  • Workspaces
  • Translation management
  • Media management (e.g. compare to Prismic)

3. When shall we use a Drupal frontend?

  • Many forms (Webforms) - possible to solve with e.g. JSON schema but can be rather complex
  • Application that exposes many edit forms
  • Many views
  • MVP, Fast prototyping of the frontend for later decoupled implementation (e.g. with Gin used on the frontend and backend)
  • Lower budget sites that requires a Drupal backend (e.g. the menu system can be hard to integrate)
  • When the team stack is not already including a decoupled framework

4. React and Vue

Why not Vue and Gridsome?

  • A matter of preference
  • React ecosystem might be more mature, more integration for really common use cases like Multilingual, Forms (Formik)

5. Gatsby and Next

  • A matter of preference
  • Should not be chosen based on the backend, both have support
  • Next might be simpler for the routing system

Resources

6. SSR (Server Side Rendering) and SSG (Static Site Generation)

  • Spoiler: in some cases, it might make sense to mix React logic with SSG.
  • Both Gatsby and Next have SSG and SSR, Gatsby is mostly used with SSG

SSR

  • Lower level of entry, less boilerplate code
  • Pain points: rehydration, isomorphism, caching

Resources

SSG

  • Incremental builds
  • Pagination, multilingual, ... must be implemented with routes - more boilerplate code

7. Integration of Gatsby and Next with Drupal

Gatsby

Gatsby module: live preview, incremental builds

Sourcing content: both JSON:API and GraphQL modules will produce a GraphQL api on Gatsby.

Next

https://next-drupal.org/

Resources

8. Learning resources

Wes Bos courses

Support, discuss: Drupal Slack

Examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment