Question
stringlengths 54
236
| Response
stringlengths 2
763
|
|---|---|
In a Next.js form using the `<input type="file">`, what is submitted to the server when the action is a string?
|
The filename
|
What component in Next.js optimizes images for performance by lazy loading and automatic resizing?
|
Image Component
|
What property can be used to create a video sitemap according to the provided reference?
|
videos
|
What method can be used in Next.js for route segments to display a loading state and prevent blocking during data requests?
|
loading.js
|
What is a potential drawback of using `getImageProps()` with the `placeholder` prop in Next.js?
|
The placeholder will never be removed.
|
What is the minimum Node.js version required for upgrading to Next.js version 13?
|
v18.17
|
What potential risk does allowing production builds to complete even if there are ESLint or TypeScript errors pose for a Next.js application?
|
Faulty deploys due to unresolved type errors or linting issues.
|
What is the requirement for a root layout in the app directory of a Next.js project, and how does it impact page rendering?
|
A root layout in the app directory is required to contain `html` and `body` tags. It impacts page rendering by preserving state, maintaining interactivity, and preventing rerender on navigation.
|
What is the method used in Next.js to revalidate data after a specified period or on-demand in version 15?
|
ISR (Incremental Static Regeneration)
|
How can you selectively disable Partial Prerendering for child segments in Next.js version 15?
|
Set `experimental_ppr` to `false` in the child segment.
|
What Next.js middleware flag introduced in version 13.1 allows maintaining URL trailing slashes for specific paths?
|
skipTrailingSlashRedirect
|
What is the recommended testing approach for async Server Components in React, given current tool limitations according to the latest Next.js documentation?
|
End-to-End Testing
|
What does the `onError` property in Next.js `next/script` components do, and under which conditions can it not be used?
|
The `onError` property in Next.js `next/script` components is used to handle errors when a script fails to load. It cannot be used with the `beforeInteractive` loading strategy and can only be used in Client Components, not Server Components.
|
How can you configure the metadata for an image's width and height in Next.js Route Handlers for the `opengraph-image` route?
|
```typescript
export const size = { width: 1200, height: 630 }
```
|
What React API is recommended to prevent sensitive session data from being exposed to the client in Next.js?
|
taintUniqueValue
|
What Node.js version is required at a minimum after upgrading to Next.js version 14?
|
18.17
|
What recommended feature in Next.js version 15 replaced the deprecated `unstable_noStore` for opting out of static rendering?
|
`connection`
|
What function is responsible for hashing a user's password prior to its storage in the database?
|
bcrypt.hash
|
What configuration option must be enabled in Next.js to use the `unauthorized` function for handling authorization errors?
|
authInterrupts
|
What is the function used to parse and validate the form fields before processing in a signup action?
|
`SignupFormSchema.safeParse`
|
What file prevents a `route.js` from existing at the same route in a Next.js application?
|
page.js
|
What option in Next.js version 13 controls the maximum memory usage of turbotrace?
|
memoryLimit
|
How can you read headers within a Route Handler in Next.js, and what must you do if you want to set headers?
|
Read headers using `headers` from `next/headers`; set headers by returning a new `Response` with new `headers`.
|
What is the default state of the `logDetail` option for turbotrace in Next.js?
|
false
|
What function is used to define dynamic metadata based on route parameters in Next.js (Vercel Managed) Server Components?
|
generateMetadata
|
How would a Next.js application behave if the `quality` prop of an image does not match any of the specified values in the `qualities` configuration?
|
400 Bad Request
|
What type of metadata should be defined using a `Metadata` object instead of the `generateMetadata` function in Next.js Server Components?
|
Static metadata
|
What version introduced the async nature of the cookies function in Next.js?
|
v15.0.0-RC
|
What is the effect of setting the `maxAge` attribute of a cookie to 0 in the context of Next.js version 15.0.0-RC?
|
It immediately expires the cookie.
|
What major change regarding React Server Components poses a challenge for security teams in Next.js?
|
React Server Components in App Router.
|
How do error boundaries in Next.js handle uncaught exceptions in client components?
|
Error boundaries in Next.js catch errors in their child components and display a fallback UI, handling uncaught exceptions in client components.
|
What configuration is required in the Next.js `next.config.js` file to safely use images hosted on a remote AWS S3 bucket?
|
```
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 's3.amazonaws.com',
pathname: '/my-bucket/**',
},
],
}
```
|
What is a restriction when calling the `forbidden` function in Next.js version v15.1.0?
|
The `forbidden` function cannot be called in the root layout.
|
What is the purpose of using the `useActionState` hook in a Next.js + TypeScript signup form?
|
To manage form state, handle submission, and display messages.
|
How does the `loading.js` file in Next.js (version 13) enhance the user experience during navigation?
|
The `loading.js` file in Next.js (version 13) enhances user experience by providing an instant loading state with React Suspense, ensuring that users see a meaningful UI immediately while content loads, making navigation feel faster and more responsive.
|
What is one limitation of using dynamic data like headers or cookies within Next.js' `unstable_cache` function as per the current version 14.0.0?
|
Accessing dynamic data sources such as headers or cookies inside a cache scope is not supported.
|
In Next.js, how can a regex path be used to match a URL segment composed only of digits, and what is the syntax to escape special characters in a static string within the path?
|
To match a URL segment composed only of digits, use `/path/:segment(\d+)`. To escape special characters, use `\\` before them, e.g., `/path/special\\(value\\)`.
|
Which Next.js function introduced in version v15.1.0 can be used to restrict access to routes based on user roles?
|
forbidden
|
What effect does setting `dynamic = 'error'` have on the default value of `dynamicParams` in Next.js?
|
`false`
|
What is the purpose of creating a `[[...slug]]` directory in a Next.js application?
|
To create an optional catch-all route segment.
|
What change is required in the `runtime` configuration to avoid errors when using an outdated method in Next.js?
|
edge
|
What HTTP status code does Next.js return when the `forbidden` function is invoked during authentication?
|
403
|
What is the default value of the `dynamic` option in Next.js when the `dynamicIO` flag is off?
|
`'auto'`
|
What version of Next.js is recommended for handling and applying nonces correctly?
|
v13.4.20+
|
What configuration option can be used to cache `GET` methods in Route Handlers in the latest Next.js version?
|
export const dynamic = 'force-static'
|
What is a key difference in behavior between templates and layouts when navigating between pages in Next.js v13.0.0?
|
Templates create a new instance and re-synchronize effects on each navigation, unlike layouts where state is preserved.
|
Which version of Next.js introduced the experimental `forbidden.js` feature?
|
v15.1.0
|
In Next.js, what is the purpose of the Full Route Cache on the server?
|
Reduce rendering cost and improve performance.
|
What function in Next.js version 13.3.0 was introduced to generate metadata for image responses?
|
generateImageMetadata
|
What is the purpose of the `generateMetadata` function in Next.js Server Components?
|
To fetch metadata that requires dynamic values.
|
What configuration file is used to specify the plugins and environment for testing with Vitest in a Next.js project using TypeScript?
|
vitest.config.mts
|
What command is used to manually execute Vitest tests according to the specified setup in a Next.js project configured with Vitest?
|
npm run test
|
What file must be used to define MDX Components in a Next.js project running version v13.1.2?
|
mdx-components.tsx
|
What is the purpose of using the `@next/bundle-analyzer` plugin in Next.js applications?
|
Analyze the size of JavaScript bundles.
|
What is the default status code used by the `redirect()` method in Next.js version 13.0.0, and why?
|
307
|
What is the role of the `useMDXComponents` function in managing MDX Components in Next.js version v13.1.2?
|
The `useMDXComponents` function manages MDX component overrides by accepting and returning an `MDXComponents` instance, allowing custom components to replace default HTML elements in MDX content.
|
What does setting the `replace` prop to `true` do in a Next.js `Link` component?
|
Replaces the current history state instead of adding a new URL into the browser's history stack.
|
What is the purpose of using a `font definitions file` when working with fonts in a Next.js application?
|
Centralize font loading and reuse across the application.
|
What ReactDOM method would you use in Next.js to start loading a resource early in the page rendering lifecycle, and what is the expected element in the head output?
|
ReactDOM.preload
```html
<link rel="preload" href="..." as="..." />
```
|
What strategy in Next.js allows a third-party script to be offloaded to a web worker, and is currently experimental according to the latest version?
|
worker
|
In Next.js, under what circumstances will navigation using the `<Link>` component trigger the `onClick` event but not the `onNavigate` event?
|
- When using modifier keys (e.g., Ctrl/Cmd + Click).
- When navigating to external URLs.
- Links with the `download` attribute.
|
How does one apply the `Inter` font using the CSS Variables method in a Next.js app?
|
Import the font and CSS file, set the variable, and use the styles:
1. Import Inter and the CSS file:
```javascript
import { Inter } from 'next/font/google';
import styles from '../styles/component.module.css';
const inter = Inter({ variable: '--font-inter' });
```
2. Apply the font in your component:
```javascript
<main className={inter.variable}>
<p className={styles.text}>Hello World</p>
</main>
```
3. Define the CSS variable:
```css
.text {
font-family: var(--font-inter);
font-weight: 200;
font-style: italic;
}
```
|
What is the default script loading strategy for third-party scripts in Next.js, according to the latest version?
|
afterInteractive
|
What ReactDOM method in Next.js is used to preemptively initiate a connection to an origin, and what is the resulting element in the head output?
|
ReactDOM preconnect method
```html
<link rel="preconnect" href="..." crossorigin />
```
|
What happens if a relative path is used in a URL-based metadata field without a configured metadataBase in Next.js?
|
Build error.
|
What types of authorization checks are recommended for controlling user access and actions within a Next.js application according to the document?
|
Optimistic and Secure authorization checks.
|
Which cache does `revalidatePath` purge immediately when used as a server action, according to the current behavior in Next.js?
|
Client-side Router Cache
|
In Next.js, how is the global application of the Inter font achieved using CSS variables with version 12 or later?
|
Use the `Inter` font with a CSS variable in `app/layout.tsx`, and apply it in `global.css` as follows:
```css
html {
font-family: var(--font-inter);
}
```
|
In Next.js, which environment variable is used as the metadataBase default value for production deployments on Vercel when it is not explicitly configured?
|
VERCEL_PROJECT_PRODUCTION_URL
|
In a production environment using Next.js version 15.2.0, what message is displayed for errors forwarded from server components?
|
A generic message with an identifier.
|
Which experimental Next.js feature allows the use of the `forbidden` and `unauthorized` APIs by configuration, and what is its status in terms of stability?
|
authInterrupts (experimental, canary channel)
|
What CSS variable is used to style `<h1>` tags with the Roboto Mono font in a Next.js application as described?
|
--font-roboto-mono
|
What header value prevents the caching of the service worker in the application using Next.js?
|
Cache-Control: no-cache, no-store, must-revalidate
|
In a Next.js application, what is the purpose of the `reset()` function in error boundary components?
|
To attempt to recover from an error by re-rendering the error boundary's contents.
|
What is the required folder to upload to your CDN to ensure server code and configurations are not publicly exposed in a Next.js project?
|
.next/static/
|
What is the primary security measure implemented to protect against clickjacking attacks in Next.js?
|
X-Frame-Options: DENY
|
What is the primary function of the `revalidate` configuration in the context of Incremental Static Regeneration in Next.js (Vercel)?
|
To specify the duration (in seconds) after which a page's cache is invalidated and a new version is generated in the background.
|
What is the primary mechanism in Next.js for dynamically adjusting routes to accommodate different locales based on user preferences?
|
Middleware
|
What is an unsupported pattern when interleaving Client and Server Components in Next.js?
|
Importing Server Components into Client Components
|
What happens to the pre-rendering of data fetching operations when the `dynamicIO` flag is enabled and not explicitly cached in Next.js's experimental configuration?
|
Data fetching operations are excluded from pre-renders.
|
What is the purpose of the `use cache` directive in Next.js when added to asynchronous functions?
|
To cache the output of the function.
|
What happens to Server Components nested inside Client Components when a new request is made to the server, according to Next.js architecture?
|
Server Components are rendered first, including those nested inside Client Components. The rendered result contains references to the locations of Client Components, which React then reconciles into a single tree.
|
What is the effect of disabling the `generateEtags` option in the `next.config.js` file for HTML pages in Next.js?
|
Disabling `generateEtags` stops the generation of etags for HTML pages, which may affect cache strategy.
|
What potential security risk can occur if untrusted URLs are used with the `router.push` method in Next.js?
|
Cross-site scripting (XSS) vulnerabilities.
|
What feature in Next.js allows for improved SEO and web shareability by moving metadata management from `index.html` into the Next.js framework?
|
Metadata API
|
Which header is automatically added to all Vercel deployments unless declared in `next.config.js` for HTTPS enforcement and what value is used specifically for `max-age`?
|
Strict-Transport-Security, max-age=63072000
|
What happens to unused Server Actions in Next.js during the build process?
|
Unused Server Actions are removed from the client bundle during the build process.
|
What must be ensured in the Google Analytics settings to automatically track client-side navigations in a Next.js application?
|
Ensure that "Enhanced Measurement" is enabled and the "Page changes based on browser history events" checkbox is selected in the Google Analytics Admin panel.
|
What directive must be added to the top of a new file to define a Client Component in Next.js's app directory?
|
'use client'
|
In Next.js, what option can be used to ensure that only paths returned by `generateStaticParams` are served, while unspecified routes return a 404?
|
dynamicParams = false
|
What is the property used to specify different languages for a URL in a Next.js sitemap with localization support?
|
alternates
|
Which specific method would you use to check if a particular cookie exists in the incoming HTTP request using Next.js, and what is the expected return type?
|
`request.cookies.has('cookieName')` returns `true` or `false`.
|
How does metadata evaluation order affect the replacement of duplicate keys in Next.js routes?
|
Metadata evaluation order affects duplicate key replacement by replacing earlier metadata entries with those from segments evaluated later in the order.
|
What is the significance of prefixing environment variables with `NEXT_PUBLIC_` in a Next.js application, specifically regarding JavaScript bundling?
|
To expose environment variables to the browser by inlining them into the JavaScript bundle during `next build`.
|
What feature did Next.js 9.1 introduce that allows for better organization of application directories?
|
`src` Directory Support
|
In a Next.js application, what is the impact of building with environment variables prefixed with `NEXT_PUBLIC_` on the ability to modify these variables at runtime, particularly in scenarios involving Docker images or Heroku pipelines?
|
Environment variables prefixed with `NEXT_PUBLIC_` are inlined at build time and cannot be modified at runtime.
|
In Next.js, how can you pass additional arguments to a Server Action within a form component?
|
In Next.js, use the JavaScript `bind` method to pass additional arguments to a Server Action within a form component.
|
What compliance feature was introduced in Next.js 9.1.7 to enhance React integration?
|
React Strict Mode Compliance and Opt-In
|
What method in Next.js allows programmatic form submission triggered by a keyboard shortcut?
|
requestSubmit()
|
In the custom Link component, what happens if there are unsaved changes and the user attempts to navigate away?
|
Navigation is blocked, and a confirmation prompt appears.
|
End of preview. Expand
in Data Studio
Samples in this benchmark were generated by RELAI using the following data source(s):
Data Source Name: Next.js
Documentation Data Source Link: https://nextjs.org/docs
Data Source License: https://github.com/vercel/next.js/blob/canary/license.md
Data Source Authors: Vercel
AI Benchmarks by Data Agents © 2025 RELAI.AI · Licensed under CC BY 4.0. Source: https://relai.ai
- Downloads last month
- 7