Lattice Flashcards
CSR
Client-Side Rendering
SSR
Server-Side Rendering
SSG
Static-Site Generation
What is Next js?
Next.js is a React framework that gives you building blocks like routing, data fetching, to create web applications
What is the difference between props and state?
Props is read-only information that’s passed to components. State is information that can change over time, usually triggered by user interaction
What is the difference between compiling and bundling in web development?
Compiling is transforming code into something parsable by browsers. Bundling is resolving your applications dependency graph and reducing the number of files
What is code-splitting?
the process of splitting the application’s bundle into smaller chunks required by each entry point. The goal is to improve the application’s initial load time by only loading the code required to run that page.
React server components
Server components are completely rendered on the server and do not require client-side JavaScript to render. In addition, server components allow developers to keep some logic on the server and only send the result of that logic to the client. This reduces the bundle size sent to the client and improves client-side rendering performance
SSR
the HTML of the page is generated on a server for each request. The generated HTML, JSON data, and JavaScript instructions to make the page interactive are then sent to the client. Which then makes the content interactive in a process called hydration
SSG
the HTML is generated on the server, but unlike server-side rendering, there is no server at runtime. Instead, content is generated once, at build time, when the application is deployed, and the HTML is stored in a CDN and re-used for each request.
What do CDN’s do?
store static content (such as HTML and image files) in multiple locations around the world and are placed between the client and the origin server. When a new request comes in, the closest CDN location to the user can respond with the cached result.
How do CDN’s increase performance?
they reduce the load on the origin because the computation doesn’t have to happen on each request. It also makes it faster for the user because the response comes from a location geographically closer to them.
The Edge
Edge servers are distributed to multiple locations around the world. But unlike CDNs, which store static content, some Edge servers can run code.
This means both caching and code execution can be done at the Edge closer to the user.
What does next js give us?
- page-based routing system
- page-based pre-rendering (SSR and SSG)
- code splitting
- sass, CSS in js support
- fast refresh
- API routes
- pre-fetching
how do you do client-side navigation with next js?
<a>homepage</a>
import Link from ‘next/link’;
how does prefetching with Next js work?
whenever Link components appear in the browser’s viewport, Next.js automatically prefetches the code for the linked page in the background. (in production)
how do you create routes in next js?
by adding files under the ‘pages’ directory.
What benefits does the Next js Image component have?
- Ensuring your image is responsive on different screen sizes
- Optimizing your images with a third-party tool or library
- Only loading images when they enter the viewport