Sr Software Engineer at Wizeline
@charliesbot
@charliesbot
npx create-react-app new-app
Text
SSR generates the full HTML for a page on the server in response to navigation. This avoids additional round-trips for data fetching and templating on the client, since it’s handled before the browser gets a response.
pages
components
about.js
home.js
blog
[id].js
pages
components
about.js
home.js
blog
[id].js
function AboutPage() {
return <h1>This is the about page</h1>
}
export default AboutPage;
pages
components
about.js
home.js
blog
[id].js
function Post({ postContent }) {
return (
<article>
{postContent}
</article>
);
}
Post.getInitialProps = async({ query }) {
const { id } = query
const postContent = await fetch(
`${api}/id`)
.then(r => r.text())
return { postContent }
}
export default Post;
pages
components
about.js
home.js
blog
[id].js
function Home() {
const { data, loading } =
useQuery(query);
if (loading) {
return <Loading />
}
return (
<View>
{data.user}
</View>
);
}
export default Home;
Next 9 was released this week 🎉
Typescript support
Link prefetch using intersection observer API
It's own CSS approach (styled-jsx)
Dynamic routing
A heuristic to automatically determine if a page can be prerendered to static HTML
Automatic code splitting
Optimized AMP by default
API routes (just add an api folder in pages!)
@charliesbot
Thanks from 🇲🇽!