SlideShare ist ein Scribd-Unternehmen logo
1 von 68
Downloaden Sie, um offline zu lesen
Next.js with Drupal,
the good parts
Sebastian Ferrari
sebas@taller.net.br
@sebas5384
● From Uruguay living in Brazil
● CTO & Co-Founder of Taller
● +15 years as developer
● ~10 years as a Drupal dev
● Co-founder of React Conf Brazil
● DevOps chairman of the
Drupal Conference LATAM (2015)
A brief history
decoupling Drupal sites
��
● Still in production
● Not fully decoupled
● Drupal 8.x
● Simple controllers serving JSON payloads
● SPA using React with Redux (and Redux Boot)
● Integration with payment gateway
Natura’s paying Web App (2016)
● Still in production
● Not fully decoupled
● Drupal 8.x and Apache Solr
● Controllers serving JSON+LD schema payloads
● SPA using React with Redux (and Redux Boot)
● Immutable.js + Reselect + Normalizr
Natura’s public and private FAQ (2016)
● ~1 million of contents
● ~900 simultaneous users
● Drupal 8.x and Apache Solr
● GraphQL module (before RC) with Apollo Client
● Next.js 4.x with custom server routing
● Edit-in-line everything!! Layout, Blocks and Contents
● Paywall using AWS Lambda’s integrated with Drupal
NSC Total publishing site (2018)
● Next.js on Kubernetes
● Drupal 8.x and Apache Solr
● GraphQL module with Apollo Client
● GraphQL gateway using stitching and delegation
● Drupal integration with the ATG Business Control
Center for demographic segmentation
● Endured a black friday!! o/
Natura’s E-Commerce (2018)
What’s
Drupal ?
What’s
?
React Framework
which takes out the
pain of building
Universal Apps
��
JS
Browser rendering
Server rendering
ZERO
CONFIGURATION !!!!
����
Why
?
Once upon a time at
the Brazil JS Conf (2014)
The 7 Principles of
Rich Web Applications
by Guillermo Rauch
1. Server rendered pages are not optional
2. Act immediately on user input
3. React to data changes
4. Control the data exchange with the server
5. Don’t break history, enhance it
6. Push code updates
7. Predict behavior
Next.js was born from
those 7 principles
SSR as first citizen
Collection of
best practices
to build Universal Apps
Who’s using it?
Flexibility
Compose Webpack configurations
with plugins
● next-plugins
● next-compose-plugins
Customize Babel configurations
Customize everything
● ./pages/_app.js
Root App component
● ./pages/_document.js
Document's markup like <html>
● ./pages/_error.js
Customize universal error pages
● (SUPER) Dynamic routing
● It’s just an ordinary express server, so
you can proxy requests, add middlewares
● Your project has specific needs for a
different web server
Customize the web server
Performance
● Common libs
● Webpack runtime
● Each page earns its own chunk
● Use import() out of the box
● Cache busting
● Defer parsing JS files when rendering the DOM
Code splitting (chunks)
Prefetching
Dev Workflow
● Start with a single file: ./pages/index.js
● Fast hot-reload
● Build bundles on-demand
● Awesome error stack traces
● Zero-config Typescript support
Dev Workflow
Documentation
��
● All the docs fit in a README file
● Examples oriented (203 in the official repo)
● Guided learning path
Documentation
Routing system
● File system as dynamic routes (demo)
● Full custom routing by using custom server
● API Routes (demo)
● Code Splitting
● Universal routing with next-routes module
Routing System
Serverless ready!
● Function as a Page
● Serverless mode:
○ Completely standalone files which don’t
require any dependencies
○ Reduce cold start
● Hybrid rendering, pre-rendering or on-demand
Serverless
When to use
?
● You use or want to use React.js to
build universal applications
● High volume of content
● High frequency of updates
● Breaking news, publish in less than 5 minutes
● Server Side Rendering (SSR)
○ Need SEO
○ Performance: First Meaningful Paint (for RUM)
When to use Next.js?
Next on Drupal
the boilerplate
GraphQL module
for Drupal
Universal Drupal
route resolver
● Try to resolve on GraphQL route() query first
● Deduce which page/component needs to load for
the entity of that route
● Use dynamic importing for better code splitting
● Universal 404 errors, both server and browser
● Redirects (already in production)
Drupal route resolver
Contextual Data
by route
● Blocks
○ Resolver by region to mount a layout
○ Each block expose a GraphQL fragment
○ Blocks can execute its own query
○ Entity reference field to blocks
● Metatags module (GraphQL)
○ Get’s Metatags from contextual entity
○ Component/Container ready to use in pages
Contextual data by route (DEMO)
Drupal Menus !
● Supports many levels of depth
● Can be used multiple times in the same page
● A Container <MenuContainer /> ready to use
Menu
Internal links
for SPA navigation
● Keep the user navigation through SPA mode
● Use <Link as=”/drupal” href=”/my-article”> to
resolve an url on Drupal, both server and client
● <HtmlText> component will patch every <a> which
has an internal (relative) href
Internal Links
Translation
🚧 WIP
Next on Drupal
the boilerplate
We need help!
🥰
● Suspense to get rid of static
hoisting of getInitalProps()
● WebAssembly (WASM) for
cross teams
○ PHP in the browser and Nodejs?
● Better serverless support
The future is bright
Stale content first
approach
● Revalidate cache on the background
● Soft purging!! please!!
● Cache-tags with soft purging
● Use a CDN (or/and Varnish) which better
fits your needs
● Use Apollo’s “cache-and-network” fetch policy to
maintain your user navigation fresh
● Perfect for serverless rendering on-demand
Serve Stale first
Credits: KeyCDN
Next.js with drupal, the good parts
Next.js with drupal, the good parts

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
 
Reactjs Basics
Reactjs BasicsReactjs Basics
Reactjs Basics
 
React js
React jsReact js
React js
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentation
 
Introduction to Web Design
Introduction to Web DesignIntroduction to Web Design
Introduction to Web Design
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
 
Server-Side Rendering (SSR) with Angular Universal
Server-Side Rendering (SSR) with Angular UniversalServer-Side Rendering (SSR) with Angular Universal
Server-Side Rendering (SSR) with Angular Universal
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
React js for beginners
React js for beginnersReact js for beginners
React js for beginners
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
Introduction to JavaScript (1).ppt
Introduction to JavaScript (1).pptIntroduction to JavaScript (1).ppt
Introduction to JavaScript (1).ppt
 
React Class Components vs Functional Components: Which is Better?
React Class Components vs Functional Components: Which is Better?React Class Components vs Functional Components: Which is Better?
React Class Components vs Functional Components: Which is Better?
 
React js - The Core Concepts
React js - The Core ConceptsReact js - The Core Concepts
React js - The Core Concepts
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
 
React hooks
React hooksReact hooks
React hooks
 
Angular Material Design.pdf
Angular Material Design.pdfAngular Material Design.pdf
Angular Material Design.pdf
 
Web development presentation
Web development presentationWeb development presentation
Web development presentation
 
Angular 14.pptx
Angular 14.pptxAngular 14.pptx
Angular 14.pptx
 
Next.js vs React | what to choose for frontend development_
Next.js vs React | what to choose for frontend development_Next.js vs React | what to choose for frontend development_
Next.js vs React | what to choose for frontend development_
 

Ähnlich wie Next.js with drupal, the good parts

Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Per Henrik Lausten
 

Ähnlich wie Next.js with drupal, the good parts (20)

Kotlin REST & GraphQL API
Kotlin REST & GraphQL APIKotlin REST & GraphQL API
Kotlin REST & GraphQL API
 
Decoupled (Headless) Drupal
Decoupled (Headless) DrupalDecoupled (Headless) Drupal
Decoupled (Headless) Drupal
 
Building RESTtful services in MEAN
Building RESTtful services in MEANBuilding RESTtful services in MEAN
Building RESTtful services in MEAN
 
From React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I startedFrom React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I started
 
GWT - Building Rich Internet Applications Using OO Tools
GWT - Building Rich Internet Applications Using OO ToolsGWT - Building Rich Internet Applications Using OO Tools
GWT - Building Rich Internet Applications Using OO Tools
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)
 
Making sense of the front-end, for PHP developers
Making sense of the front-end, for PHP developersMaking sense of the front-end, for PHP developers
Making sense of the front-end, for PHP developers
 
CON6423: Scalable JavaScript applications with Project Nashorn
CON6423: Scalable JavaScript applications with Project NashornCON6423: Scalable JavaScript applications with Project Nashorn
CON6423: Scalable JavaScript applications with Project Nashorn
 
Post-relational databases: What's wrong with web development? v3
Post-relational databases: What's wrong with web development? v3Post-relational databases: What's wrong with web development? v3
Post-relational databases: What's wrong with web development? v3
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
 
Netty training
Netty trainingNetty training
Netty training
 
Decoupled drupal DcRuhr
Decoupled drupal DcRuhrDecoupled drupal DcRuhr
Decoupled drupal DcRuhr
 
Presentation on octobercms
Presentation on octobercmsPresentation on octobercms
Presentation on octobercms
 
Full stack development
Full stack developmentFull stack development
Full stack development
 
BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013
 
Netty training
Netty trainingNetty training
Netty training
 
Grails 101
Grails 101Grails 101
Grails 101
 
WebDev Simplified React.js.pptx
WebDev Simplified React.js.pptxWebDev Simplified React.js.pptx
WebDev Simplified React.js.pptx
 
Architektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan KrausArchitektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan Kraus
 
React native introduction (Mobile Warsaw)
React native introduction (Mobile Warsaw)React native introduction (Mobile Warsaw)
React native introduction (Mobile Warsaw)
 

Mehr von Taller Negócio Digitais

Mehr von Taller Negócio Digitais (20)

Indo além do técnico para desenvolver sistemas que evoluem na velocidade do...
Indo além do técnico para desenvolver sistemas que evoluem na velocidade do...Indo além do técnico para desenvolver sistemas que evoluem na velocidade do...
Indo além do técnico para desenvolver sistemas que evoluem na velocidade do...
 
Discovery kanban
Discovery kanbanDiscovery kanban
Discovery kanban
 
Taller Negócios Digitais
Taller Negócios DigitaisTaller Negócios Digitais
Taller Negócios Digitais
 
De um sistema legado para micro serviços com GraphQL
De um sistema legado para micro serviços com GraphQLDe um sistema legado para micro serviços com GraphQL
De um sistema legado para micro serviços com GraphQL
 
Gestão Ágil com Fluxo Unificado
Gestão Ágil com Fluxo UnificadoGestão Ágil com Fluxo Unificado
Gestão Ágil com Fluxo Unificado
 
Alinhando Discovery com Delivery usando Upstream Kanban
Alinhando Discovery com Delivery usando Upstream KanbanAlinhando Discovery com Delivery usando Upstream Kanban
Alinhando Discovery com Delivery usando Upstream Kanban
 
Lições Aprendidas com Fluxo Unificado
Lições Aprendidas com Fluxo UnificadoLições Aprendidas com Fluxo Unificado
Lições Aprendidas com Fluxo Unificado
 
Como a liderança descentralizada tornou a Taller mais efetiva
Como a liderança descentralizada tornou a Taller mais efetivaComo a liderança descentralizada tornou a Taller mais efetiva
Como a liderança descentralizada tornou a Taller mais efetiva
 
Métricas no Fluxo Unificado
Métricas no Fluxo UnificadoMétricas no Fluxo Unificado
Métricas no Fluxo Unificado
 
Práticas e ferramentas de feedback: potencializando a cultura da confiança
Práticas e ferramentas de feedback: potencializando a cultura da confiançaPráticas e ferramentas de feedback: potencializando a cultura da confiança
Práticas e ferramentas de feedback: potencializando a cultura da confiança
 
Como preparar seu time para receber feedback - Scrum Gathering Rio 2017
Como preparar seu time para receber feedback - Scrum Gathering Rio 2017Como preparar seu time para receber feedback - Scrum Gathering Rio 2017
Como preparar seu time para receber feedback - Scrum Gathering Rio 2017
 
Vacinando mais de 200 mil pessoas com ReactJS e GraphQL
Vacinando mais de 200 mil pessoas com ReactJS e GraphQLVacinando mais de 200 mil pessoas com ReactJS e GraphQL
Vacinando mais de 200 mil pessoas com ReactJS e GraphQL
 
Taller – Treinamentos e consultorias
Taller – Treinamentos e consultoriasTaller – Treinamentos e consultorias
Taller – Treinamentos e consultorias
 
Taller - Ateliê de desenvolvimento de software
Taller - Ateliê de desenvolvimento de softwareTaller - Ateliê de desenvolvimento de software
Taller - Ateliê de desenvolvimento de software
 
Introdução ao Fluxo Unificado - TDC Florianópolis 2017
Introdução ao Fluxo Unificado - TDC Florianópolis 2017Introdução ao Fluxo Unificado - TDC Florianópolis 2017
Introdução ao Fluxo Unificado - TDC Florianópolis 2017
 
Javascript Funcional - TDC Florianópolis 2017
Javascript Funcional - TDC Florianópolis 2017Javascript Funcional - TDC Florianópolis 2017
Javascript Funcional - TDC Florianópolis 2017
 
11 maneiras de compartilhar conhecimento - TDC Florianópolis 2017
11 maneiras de compartilhar conhecimento  - TDC Florianópolis 201711 maneiras de compartilhar conhecimento  - TDC Florianópolis 2017
11 maneiras de compartilhar conhecimento - TDC Florianópolis 2017
 
Kanban no Fluxo Unificado de Portfolio de Projetos - Agile Brazil 2016
Kanban no Fluxo Unificado de Portfolio de Projetos - Agile Brazil 2016Kanban no Fluxo Unificado de Portfolio de Projetos - Agile Brazil 2016
Kanban no Fluxo Unificado de Portfolio de Projetos - Agile Brazil 2016
 
Programação Eficaz - Agile Trends Floripa 2016
Programação Eficaz -  Agile Trends Floripa 2016Programação Eficaz -  Agile Trends Floripa 2016
Programação Eficaz - Agile Trends Floripa 2016
 
Trabalhando a cultura do feedback. Por onde começar?
Trabalhando a cultura do feedback. Por onde começar?Trabalhando a cultura do feedback. Por onde começar?
Trabalhando a cultura do feedback. Por onde começar?
 

Kürzlich hochgeladen

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Kürzlich hochgeladen (20)

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 

Next.js with drupal, the good parts

  • 1. Next.js with Drupal, the good parts Sebastian Ferrari sebas@taller.net.br @sebas5384
  • 2. ● From Uruguay living in Brazil ● CTO & Co-Founder of Taller ● +15 years as developer ● ~10 years as a Drupal dev ● Co-founder of React Conf Brazil ● DevOps chairman of the Drupal Conference LATAM (2015)
  • 3. A brief history decoupling Drupal sites ��
  • 4. ● Still in production ● Not fully decoupled ● Drupal 8.x ● Simple controllers serving JSON payloads ● SPA using React with Redux (and Redux Boot) ● Integration with payment gateway Natura’s paying Web App (2016)
  • 5. ● Still in production ● Not fully decoupled ● Drupal 8.x and Apache Solr ● Controllers serving JSON+LD schema payloads ● SPA using React with Redux (and Redux Boot) ● Immutable.js + Reselect + Normalizr Natura’s public and private FAQ (2016)
  • 6. ● ~1 million of contents ● ~900 simultaneous users ● Drupal 8.x and Apache Solr ● GraphQL module (before RC) with Apollo Client ● Next.js 4.x with custom server routing ● Edit-in-line everything!! Layout, Blocks and Contents ● Paywall using AWS Lambda’s integrated with Drupal NSC Total publishing site (2018)
  • 7. ● Next.js on Kubernetes ● Drupal 8.x and Apache Solr ● GraphQL module with Apollo Client ● GraphQL gateway using stitching and delegation ● Drupal integration with the ATG Business Control Center for demographic segmentation ● Endured a black friday!! o/ Natura’s E-Commerce (2018)
  • 10.
  • 11. React Framework which takes out the pain of building Universal Apps ��
  • 14. Why ?
  • 15. Once upon a time at the Brazil JS Conf (2014)
  • 16. The 7 Principles of Rich Web Applications by Guillermo Rauch
  • 17. 1. Server rendered pages are not optional 2. Act immediately on user input 3. React to data changes 4. Control the data exchange with the server 5. Don’t break history, enhance it 6. Push code updates 7. Predict behavior
  • 18. Next.js was born from those 7 principles
  • 19. SSR as first citizen
  • 20. Collection of best practices to build Universal Apps
  • 23. Compose Webpack configurations with plugins ● next-plugins ● next-compose-plugins
  • 24.
  • 25.
  • 27. Customize everything ● ./pages/_app.js Root App component ● ./pages/_document.js Document's markup like <html> ● ./pages/_error.js Customize universal error pages
  • 28. ● (SUPER) Dynamic routing ● It’s just an ordinary express server, so you can proxy requests, add middlewares ● Your project has specific needs for a different web server Customize the web server
  • 29.
  • 31. ● Common libs ● Webpack runtime ● Each page earns its own chunk ● Use import() out of the box ● Cache busting ● Defer parsing JS files when rendering the DOM Code splitting (chunks)
  • 32.
  • 33.
  • 34.
  • 35.
  • 38. ● Start with a single file: ./pages/index.js ● Fast hot-reload ● Build bundles on-demand ● Awesome error stack traces ● Zero-config Typescript support Dev Workflow
  • 40. ● All the docs fit in a README file ● Examples oriented (203 in the official repo) ● Guided learning path Documentation
  • 42. ● File system as dynamic routes (demo) ● Full custom routing by using custom server ● API Routes (demo) ● Code Splitting ● Universal routing with next-routes module Routing System
  • 44. ● Function as a Page ● Serverless mode: ○ Completely standalone files which don’t require any dependencies ○ Reduce cold start ● Hybrid rendering, pre-rendering or on-demand Serverless
  • 46. ● You use or want to use React.js to build universal applications ● High volume of content ● High frequency of updates ● Breaking news, publish in less than 5 minutes ● Server Side Rendering (SSR) ○ Need SEO ○ Performance: First Meaningful Paint (for RUM) When to use Next.js?
  • 47. Next on Drupal the boilerplate
  • 49.
  • 51. ● Try to resolve on GraphQL route() query first ● Deduce which page/component needs to load for the entity of that route ● Use dynamic importing for better code splitting ● Universal 404 errors, both server and browser ● Redirects (already in production) Drupal route resolver
  • 53. ● Blocks ○ Resolver by region to mount a layout ○ Each block expose a GraphQL fragment ○ Blocks can execute its own query ○ Entity reference field to blocks ● Metatags module (GraphQL) ○ Get’s Metatags from contextual entity ○ Component/Container ready to use in pages Contextual data by route (DEMO)
  • 55. ● Supports many levels of depth ● Can be used multiple times in the same page ● A Container <MenuContainer /> ready to use Menu
  • 56.
  • 57.
  • 59. ● Keep the user navigation through SPA mode ● Use <Link as=”/drupal” href=”/my-article”> to resolve an url on Drupal, both server and client ● <HtmlText> component will patch every <a> which has an internal (relative) href Internal Links
  • 60.
  • 62. Next on Drupal the boilerplate We need help! 🥰
  • 63. ● Suspense to get rid of static hoisting of getInitalProps() ● WebAssembly (WASM) for cross teams ○ PHP in the browser and Nodejs? ● Better serverless support The future is bright
  • 65. ● Revalidate cache on the background ● Soft purging!! please!! ● Cache-tags with soft purging ● Use a CDN (or/and Varnish) which better fits your needs ● Use Apollo’s “cache-and-network” fetch policy to maintain your user navigation fresh ● Perfect for serverless rendering on-demand Serve Stale first