NextJS Flashcards

1
Q

What is Next.js?

A

A React framework that …

  • handles the tooling and configuration needed for React,
  • provides additional structure, features and optimizations for your application
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are 5 differences between React and Next.js?

A
  1. Next.js has its own compiler
  2. Fast Refresh comes pre-configured with Next.js
  3. JS and CSS files are automatically minified in Next.js
  4. Next.js has built-in support for code-splitting
  5. Pages in Next.js can be rendered client-side, server-side or with static site generation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What enables routing in Next.js?

A

Files added to the ‘pages’ folder will automatically be rendered with the matching url.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What element should be used for internal links?

A

the Link element
———————————————————————————————-

import Link from ‘next/link’;
Example

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What element should be used for external links?

A

The anchor element (<a></a>)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How/where should attributes like ‘className’ be added to links?

A

Inside the anchor tag, which is wrapped inside Next’ Link element
———————————————————————————————-

import Link from ‘next/link’;

<a>link</a>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can metadata such as be modified?

A

By importing and using Next’ element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can the element be customized in Next.js?

A

By creating a ‘_document.js’ page inside the ‘pages’ folder (/pages/_document.js)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the advantage of the Next.js element vs the HTML element?

A

It optimizes when additional scripts are fetched and executed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What additional properties does the element have?

A
  1. strategy - controls when the third-party script should load (e.g. ‘lazyOnload’)
  2. onLoad - runs javaScript code right after the script has finished loading
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What styling methods does ext.js have built-in support for?

A
  1. CSS modules
  2. Sass
  3. PostCSS libraries like Tailwind Css
  4. CSS-in-JS libraries like styled-jsx
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can global styles be loaded?

A

By importing the styles into the ‘pages/_app.js’ file (cannot be imported in other files).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What function is used for static generation with data?

A

getStaticProps()
———————————————————————————————-

export async function getStaticProps() {

  // get external data  
  const data = ... 
  // return props to pass to the component
  return { props: ... }

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly