Next.js Questions et reponses d'entretien
Question 21. Explain the concept of 'Shallow Routing' in Next.js.
Shallow Routing in Next.js allows you to change the URL without running data fetching methods again. It can be achieved using the 'shallow' option in the 'Link' component.
Question 22. How can you configure a custom server in Next.js?
You can configure a custom server in Next.js by creating a 'server.js' file in your project. However, using a custom server is discouraged in most cases, and it may bypass some optimizations.
Question 23. Explain the concept of 'Global CSS' in Next.js.
Global CSS in Next.js refers to styles that are applied globally across all components. It can be achieved by importing a CSS file into the 'pages/_app.js' file.
Question 24. How can you implement code splitting in a Next.js application?
Code splitting in Next.js is automatically handled by the framework. Each page becomes a separate chunk, and dynamic imports can be used to further split code based on user interactions.
Question 25. Explain the purpose of the 'getStaticPaths' function in dynamic routes.
'getStaticPaths' is used in dynamic routes to specify which paths should be pre-rendered at build time. It returns an array of possible values for the dynamic segments in the route.
Les plus utiles selon les utilisateurs :