More at laymonage.com/about
More at laymonage.com/about
β Blazing fast
β Quick to develop
β Cheap and easier to host
β Canβt be tailored to individual visitors
β Functionalities limited by client and premade assets
β Unable to store external API secrets
β Can provide tailored experience
β More powerful and flexible
β Allows secure authentication for external APIs
β Slower compared to static websites
β Require knowledge of backend programming
β Expensive and harder to host
"The React Framework for Production"
Allows pre-rendering in two forms:
Best of both worlds!
In additionβ¦
getStaticProps
export default function Home(props) { ... }
export async function getStaticProps() {
// Get external data from the file system, API, DB, etc.
const data = ...
// The value of the `props` key will be
// passed to the `Home` component
return {
props: ...
}
}
Data is only "fetched" and rendered into the pages at build time.
What if the data is constantly updated?
Stale data! π¦
Solution: fetch data at request time! π
getServerSideProps
export default function Home(props) { ... }
export async function getServerSideProps(context) {
return {
props: {
// props for your component
}
}
}
2021 Β· laymonage