Gatsby as a replacement fro create-react-app

A presentation at Gatsby Days in September 2019 in by Khaled Garbaya

Slide 1

Slide 1

GAT S BY A S A REPLACEMENT FOR C R E A T E - R E A C T- A P P @khaled_garbaya. https://k4d.dev

Slide 2

Slide 2

HI, I’M KHALED @khaled_garbaya www.k4d.dev www.learnjamstack.com @khaled_garbaya. https://k4d.dev

Slide 3

Slide 3

I’M FROM TUNISIA @khaled_garbaya. https://k4d.dev

Slide 4

Slide 4

S T A R WA R S E P I S O D E 1 WA S FILMED IN TUNISIA TATAO U I N E I S A N AC T UA L C I T Y IN TUNISIA @khaled_garbaya. https://k4d.dev

Slide 5

Slide 5

FROM THE PICTURE GUESS HOW MANY PRS I MADE TO GAT S BY @khaled_garbaya. https://k4d.dev

Slide 6

Slide 6

LAST TIME I CHECKED 22 @khaled_garbaya. https://k4d.dev

Slide 7

Slide 7

GAT S BY A S A REPLACEMENT FOR C R E A T E - R E A C T- A P P @khaled_garbaya. https://k4d.dev

Slide 8

Slide 8

I S N ’ T GAT S BY A S TAT I C S I T E G E N E R AT O R ? @khaled_garbaya. https://k4d.dev

Slide 9

Slide 9

IT’S MORE T HA N T HAT @khaled_garbaya. https://k4d.dev

Slide 10

Slide 10

I T G I V E S YO U H T M L T O S TA R T W I T H @khaled_garbaya. https://k4d.dev

Slide 11

Slide 11

T H E N , R E H Y D R AT E S I T I N T O A F U L LY- F L E D G E D REACT APP @khaled_garbaya. https://k4d.dev

Slide 12

Slide 12

CRA VS GAT S BY @khaled_garbaya. https://k4d.dev

Slide 13

Slide 13

THEY ARE SIMILAR @khaled_garbaya. https://k4d.dev

Slide 14

Slide 14

THEY WORK WITH REACT @khaled_garbaya. https://k4d.dev

Slide 15

Slide 15

T H EY H E L P YO U SET UP AN A P P L I CAT I O N @khaled_garbaya. https://k4d.dev

Slide 16

Slide 16

THEY REMOVE MUCH OF T H E C O N F I G U R AT I O N HEADACHE. @khaled_garbaya. https://k4d.dev

Slide 17

Slide 17

HOWEVER … @khaled_garbaya. https://k4d.dev

Slide 18

Slide 18

GAT S BY OFFERS MORE @khaled_garbaya. https://k4d.dev

Slide 19

Slide 19

S TAT I C R E N D E R I N G N O S E RV E R S NEEDED @khaled_garbaya. https://k4d.dev

Slide 20

Slide 20

S E O F R I E N D LY APP @khaled_garbaya. https://k4d.dev

Slide 21

Slide 21

AU T O M AT I C ROUTING @khaled_garbaya. https://k4d.dev

Slide 22

Slide 22

ACCESSIBLE ROUTING @khaled_garbaya. https://k4d.dev

Slide 23

Slide 23

UNIFIED GRAPHQL D ATA L AY E R @khaled_garbaya. https://k4d.dev

Slide 24

Slide 24

EXCELLENT ECOSYSTEM OF PLUGINS @khaled_garbaya. https://k4d.dev

Slide 25

Slide 25

A FEW GOTCHA @khaled_garbaya. https://k4d.dev

Slide 26

Slide 26

THE WINDOW OBJECT @khaled_garbaya. https://k4d.dev

Slide 27

Slide 27

const isBrowser = typeof window !== undefined exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => { if (stage === “build-html”) { actions.setWebpackConfig({ module: { rules: [ { test: /moduleName/, use: loaders.null(), }, ], }, }) } } @khaled_garbaya. https://k4d.dev

Slide 28

Slide 28

YO U C A N U S E GAT S BY W I T H O U T GRAPHQL @khaled_garbaya. https://k4d.dev

Slide 29

Slide 29

exports.createPages = async ({ actions: { createPage } }) #=> { #// getPokemonData is a function that fetches our data const allPokemon = await getPokemonData([“pikachu”, “charizard”, “squirtle”]) #// Create a page that lists all Pokémon. createPage({ path: /, component: require.resolve(“./src/templates/all-pokemon.js”), context: { allPokemon }, }) #// Create a page for each Pokémon. allPokemon.forEach(pokemon #=> { createPage({ path: /pokemon/${pokemon.name}/, component: require.resolve(“./src/templates/pokemon.js”), context: { pokemon }, }) }) } @khaled_garbaya. https://k4d.dev

Slide 30

Slide 30

T HA N K YO U k4d.dev/talk/cra-vs-gatsby @khaled_garbaya. https://k4d.dev