Why?
https://developers.facebook.com/tools/debug/sharing/https://cards-dev.twitter.com/validator
How it works?
Pros?
Cons?
configuration
yarn add --dev react-snapconfiguration
{
"scripts": {
"postbuild": "react-snap"
}
}configuration
import { hydrate, render } from "react-dom";
const rootElement = document.getElementById("root");
if (rootElement.hasChildNodes()) {
hydrate(<App />, rootElement);
} else {
render(<App />, rootElement);
}TODO
How it works?
Pros
Cons
npm install -g gatsby-cligatsby new my-ssr-siteyarn developyarn buildimport React from "react"
import Layout from "../components/layout"
import SEO from "../components/seo"
const NotFoundPage = () => (
<Layout>
<SEO title="404: Not found" />
<h1>NOT FOUND</h1>
<p>You just hit a route that doesn't exist... the sadness.</p>
</Layout>
)
export default NotFoundPage
src/pages/404.js
import React from "react";
import { Link } from "gatsby";
import { Helmet } from 'react-helmet';
const IndexPage = ({ pageContext: { data }}) => (
<div style={{ textAlign: 'center' }}>
<Helmet title="Homepage - Pokemon App" />
<div>
{data.map((item) =>
<div key={item.name}>
<Link to={'/details/' + item.name}>{item.name}</Link>
</div>
)}
</div>
</div>
);
export default IndexPage;
src/templates/index.js
const fetch = require('isomorphic-fetch');
const getAllPokemon = async () => {
const rawData = await fetch('https://pokeapi.co/api/v2/pokemon?limit=10');
const { results } = await rawData.json();
return results;
};gatsby-node.js
exports.createPages = async ({ actions: { createPage } }) => {
createPage({
// page route
path: `/`,
// template file
component: require.resolve("./src/templates/page-template.js"),
// context data passed to the template
context: {},
});
};gatsby-node.js
exports.createPages = async ({ actions: { createPage } }) => {
const allPokemon = await getAllPokemon();
createPage({
path: `/`,
component: require.resolve("./src/templates/all.js"),
context: { data: allPokemon },
});
};gatsby-node.js
exports.createPages = async ({ actions: { createPage } }) => {
const allPokemon = await getAllPokemon();
createPage({
path: `/`,
component: require.resolve("./src/templates/all.js"),
context: { data: allPokemon },
});
allPokemon.forEach(async ({ name }) => {
createPage({
path: `/details/${name}/`,
component: require.resolve("./src/templates/details.js"),
context: { name },
});
});
};gatsby-node.js
How it works?
Pros?
Cons?
configuration
yarn add next react react-domconfiguration
{
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
}
}configuration
function Home() {
return <div>Welcome to Next.js!</div>
}
export default HomeTODO
How it works?
Caches rendered pages and serves them for SEO / social bots
Pros?
Cons?
configuration
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
netlify.toml
configuration
configuration
Build & Deploy / Post processing