Next.js Flashcards
(65 cards)
What does React render to create web pages?
JSX and TSX code. Next.js provides another way to do this.
What are some key benefits of Next.js over React?
Improved initial page load performance, SEO, and user experience on slow devices/networks.
What are the two rendering methods for JSX/TSX code?
Client Side Rendering (CSR) and Server Side Rendering (SSR).
How does Client Side Rendering (CSR) work?
JSX/TSX is compiled to JavaScript and sent to the browser, which renders the webpage by manipulating the DOM.
How does Server Side Rendering (SSR) work?
JSX/TSX is rendered to HTML on the server and sent to the browser with minimal JavaScript for reactivity.
Which rendering methods does React support?
Only Client Side Rendering (CSR).
Which rendering methods does Next.js support?
Both CSR and SSR. By default it performs SSR.
What is a major drawback of CSR?
Slow initial page load due to downloading and executing a large JavaScript bundle.
What is a major benefit of SSR?
Faster initial loading as the browser receives pre-rendered HTML.
What is hydration in Next.js?
The process of running JavaScript on the HTML received from SSR to make the page interactive.
How do you specify a component to use CSR in Next.js?
Add ‘use client’ at the top of the component file.
How has the role of React changed with the emergence of Next.js?
React is often used within frameworks like Next.js instead of standalone.
React is a library that lets you put components together, but it doesn’t prescribe how to do routing and data fetching. To build an entire app with React, we recommend a full-stack React framework like Next.js
What command creates a new Next.js project?
Use the terminal and run: npx create-next-app@latest
What does routing mean in Next.js?
Handling a client’s request based on its URL.
What are the two routers in Next.js?
Pages Router and App Router.
Which Next.js router supports React’s latest features?
The App Router.
How do you containerise a Next.js project?
Add Dockerfile and .dockerignore, then use docker build and docker run commands.
What is the RootLayout component responsible for?
Formatting common to every page, like buttons and banners.
What does the Home component define?
The specific content for the route, using CSR.
Where do you define routes using the App Router?
In the app directory using folders and files.
A route is a single path of nested folders, following the file-system hierarchy from the root folder down to a final leaf folder that includes a page.js file.
What is a URL segment?
what is a URL path?
Part of a URL path delimited by slashes. Each folder in the nested hierarchy represents a route segment
Part of the URL that comes after the domain (composed of segments).
How do you create a nested route like /dashboard/settings?
You build a directory structure inside the app directory that mimics the route structure you want to be able to visit.
Nest folders: app/dashboard/settings/page.js.
How do you define a dynamic route segment in Next.js?
You use dynamic segments, that are filled in at request time or pre rendered at build time.
Use square brackets in folder names [folderName], e.g., [id] or [slug].
How are dynamic segment values accessed?,
They are passed as the params prop to layout/page functions.