What does API stand for?
Application Programming Interface (API)
What are the four main HTTP-Verbs?
GET, POST, PUT, DELETE
In Next.js, how do you link between pages/URL’s?
Use /pages folder to have URL’s automatically. E.g.
/pages/index.js –> /
/pages/about/index.js –> /about
/pages/about/home.js –> /about/home
What does an API generally do?
What is an API Endpoint?
A specific URL where the data or functions you want are exposed.
In Next.js, how do you pass props to a function/component?
Use getStaticProps() in same file to return props. e.g:
export async function getStaticProps() {
const person = await fetch('/person-api');
return {
props: { person }
}
}export default function Person({ person }) {
}
What is the difference between client-side- and server-side-rendering?
Client side rendering renders an empty DOM and then fills it up in the browser (bad for SEO, etc.).
Server side rendering renders the finished HTML on the server and then returns the finished product to the browser.
In Next.js, how do you make a dynamic URL?
Use brackets notation –> [id].js
e.g:
/people
[name].js
URL’s:
/people/adam
/people/bob
/people/cathy
What is Static Generation?
Static Generation means that the HTML is generated at build time and will be reused on each request.
This is good for pages that can be pre-rendered ahead of a user’s request.
In order to make a page use Static Generation, you can export getStaticProps along with the page component.
What is Server-Side-Rendering (SSR)?
Server-Side-Rendering means that the HTML is generated on each request.
This results in slower performance than Static Generation, so use it only if needed or for a good reason.
In order to make a page use SSR, export getServerSideProps along with the page component.
What is the boilerplate for SSR?
export async function getServerSideProps(context) {
return {
props: {}, // will be passed to the page component
}
}