Next.js is a popular open-source web development framework built on top of React, created by Vercel. It is designed to enable developers to build server-side rendered (SSR) and static web applications quickly and efficiently.
In this article, we will share some next.js MCQ questions with answers that helps you to prepare for your next interview.
Multiple Choice Questions with Answers
Q1. In Next.js, which function is used to fetch data at build time?
- getInitialProps
- getStaticProps
- getServerSideProps
- useEffect
=> getStaticProps
Q2. What does each file in the pages directory correspond to in a Next.js application?
- A component
- A route
- A stylesheet
- An API endpoint
=> A route
Q3. SSR stands for?
- Server static resources
- Server side response
- Server Side Rendering
- None of these
=> Server Side Rendering
Q4. Which of the following methods in Next.js is used for server-side rendering on each request?
- getStaticProps
- getStaticPaths
- getServerSideProps
- getInitialProps
=> getServerSideProps
Q5. What file is used to define custom server configuration in Next.js?
- server.js
- next.config.js
- customServer.js
- nextServer.js
=> next.config.js
Q6. How do you enable Incremental Static Regeneration in Next.js?
- By using getStaticProps with revalidate key
- By using getServerSideProps
- By using getInitialProps
- By using useEffect
=> By using getStaticProps with revalidate key
Q7. Which file is used to customize the HTML document in Next.js?
- _app.js
- _document.js
- index.js
- _html.js
=> _document.js
Q8. Which of the following is a valid way to define dynamic routes in Next.js?
- [param].js
- {param}.js
- (param).js
- [{param}].js
=> [param].js
Q9. getStaticProps() function runs at?
- Runtime
- Compile time
- Build time
- Both
=> Build time
Q10. Does getStaticProps have access to the incoming request?
- Yes
- No
=> No
Visit Next JS MCQ for more questions
Originally published at https://codeymaze.com on June 8, 2024.