Atila
I'm on a mission to make code simple. When not recording screencasts or courses, you may find me either writing and talking about jamstack, performance, or developer tooling.
2022
@AtilaFassina
@AtilaFassina
@AtilaFassina
2022 - Speaker
Optimistic UX
Expert Panelist
Reviewer
Author
Smashing
DX Engineer
atila.io
@AtilaFassina
@AtilaFassina
π©πͺΒ Server
πΒ Edge
...
π©πͺ
πΊπΈ
π―π΅
How to:
βͺAvoid downtime?
βͺ Distribute cache?
βͺ Update cache?
βͺ Cut costs... ? π¬
π
π
π
@AtilaFassina
π©πͺ
πΊπΈ
π―π΅
How to:
βͺ no downtime.
βͺ cache distribution.
βͺ instant propagation.
βͺ predictable costs.
@AtilaFassina
π©πͺ
πΊπΈ
π―π΅
Server Location β
How to:
βͺ Persist more.
βͺ Minimize rountrips.
@AtilaFassina
@AtilaFassina
@AtilaFassina
@AtilaFassina
@AtilaFassina
: manages Node.js versions and toolchain.
@AtilaFassina
git clone \
git@github.com:atilafassina/smashing-next.git \
directory-name
cd smashing-masterclass && npm i && npm run dev
@AtilaFassina
mkdir new-directory
npx degit atilafassina/smashing-next
git init && npm i
@AtilaFassina
@AtilaFassina
export const getStaticProps = async () => {
// fetch data
return {
props: {
// view props
}
}
}
βͺ Data is added to client-side bundle.
@AtilaFassina
export const getStaticProps = async () => {
// fetch data
return {
props: {
// view props
},
revalidate: 60
}
}
βͺ Data is added to client-side bundle.
βͺ Server re-renders page every 60 seconds.
@AtilaFassina
export const getServerSideProps = async () => {
// fetch data
return {
props: {
// view props
}
}
}
βͺ API Route provided for client-side navigation.
βͺ Re-renders on every hard-navigation request.
@AtilaFassina
export const getServerSideProps = async () => {
return {
redirect: {
destination: '/',
permanent: false,
}
}
}
βͺ Can also return redirects.
βͺ `permanent: true` is 301 redirect
@AtilaFassina
export const getServerSideProps = async () => {
return {
notFound: true
}
}
βͺ Or not found.
@AtilaFassina
export const getStaticPaths = async () => {
// fetch data
return {
paths: ['slug1', 'slug2'],
fallback: false
}
}
βͺ Combined with getStaticProps.
βͺ fallback: false, true, or βblockingβ.
@AtilaFassina
π true: has 3 different behaviours.
π false: any paths not returned will go to the 404 page.
π βblockingβ: render pages not in returned paths via SSR.
1. Serves a loading state while renders page.
2. Serves from cache pages already rendered.
3. Serves bots and crawlers on-demand (SSR).
@AtilaFassina
export const getStaticPaths = async () => {
// fetch data
return {
paths: ['/pricing', '/feature-page'],
fallback: true // or 'blocking'
}
}
βͺ Pre-Render most important on build time.
βͺ Rest is rendered and cached on-demand.
@AtilaFassina
@AtilaFassina
@AtilaFassina
@AtilaFassina
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
@AtilaFassina
/** @type {import('tailwindcss').Config} */
module.exports = {
mode: 'jit',
content: [
'./app/**/*.{js,ts,jsx,tsx}',
'./pages/**/*.{js,ts,jsx,tsx}',
'./components/**/*.{js,ts,jsx,tsx}',
'./layouts/**/*.{js,ts,jsx,tsx}',
],
theme: {},
plugins: [],
}
@AtilaFassina
@AtilaFassina
REACT
QUERY
@AtilaFassina
By Atila