Next.js Quiz ( Beginner ) - All Questions
This easy-level Next.js quiz is designed for beginners who want to test and strengthen their fundamentals. It covers core concepts like routing, rendering, components, and basic features of Next.js in a clear, interview-friendly way.
Question 1: What is Next.js primarily used for?
- Building mobile applications
- Building React applications with advanced features
- Database management
- Game development
Explanation: Next.js is a React framework that adds features like routing, SSR, and performance optimizations.
Question 2: Next.js is built on top of which library?
Explanation: Next.js extends React to provide a full-stack framework.
Question 3: Which folder is responsible for routing in traditional Next.js projects?
- components
- routes
- pages
- public
Explanation: The pages folder automatically maps files to routes.
Question 4: What route is created by a file named index.js inside the pages folder?
Explanation: index.js inside pages maps to the root route (/).
Question 5: Which command starts the Next.js development server?
- npm start
- npm run build
- npm run dev
- next build
Explanation: npm run dev starts the development server in Next.js.
Question 6: What is the default port for a Next.js development server?
Explanation: Next.js runs on port 3000 by default.
Question 7: Which rendering methods are supported by Next.js?
- Only client-side rendering
- Only server-side rendering
- Only static generation
- Client-side, server-side, and static generation
Explanation: Next.js supports CSR, SSR, and SSG.
Question 8: Which file is used to customize the root component in Next.js?
- _document.js
- _app.js
- index.js
- main.js
Explanation: _app.js allows customization of the root React component.
Question 9: What is the purpose of the Link component in Next.js?
- To refresh the page
- To navigate using client-side routing
- To fetch data
- To style links
Explanation: Link enables fast client-side navigation between pages.
Question 10: Which hook is used to access routing information in Next.js?
- useHistory
- useRoute
- useRouter
- usePath
Explanation: useRouter provides access to route details in Next.js.
Question 11: Which file allows you to customize the HTML document structure?
- _app.js
- _html.js
- _document.js
- index.html
Explanation: _document.js customizes the HTML and body structure.
Question 12: What does Static Site Generation (SSG) mean in Next.js?
- Pages generated on every request
- Pages generated in the browser
- Pages generated at build time
- Pages generated using APIs only
Explanation: SSG generates pages at build time for better performance.
Question 13: Which function is used for static generation with data?
- getServerSideProps
- getStaticProps
- getInitialProps
- useEffect
Explanation: getStaticProps fetches data at build time.
Question 14: Which function enables server-side rendering in Next.js?
- getStaticProps
- getClientSideProps
- getServerSideProps
- useState
Explanation: getServerSideProps runs on each request on the server.
Question 15: Where should API routes be placed in Next.js?
- api folder
- server folder
- pages/api folder
- backend folder
Explanation: API routes are created inside the pages/api directory.
Question 16: Next.js API routes run on which side?
- Client side
- Server side
- Browser only
- CDN only
Explanation: API routes execute on the server.
Question 17: Which component is recommended for images in Next.js?
- img
- picture
- Image from next/image
- Media
Explanation: The Image component provides automatic optimization.
Question 18: What is the purpose of the public folder in Next.js?
- To store components
- To store static assets
- To store routes
- To store APIs
Explanation: The public folder stores static files like images and icons.
Question 19: Which file contains custom Next.js configuration?
- package.json
- next.config.js
- config.json
- webpack.js
Explanation: next.config.js is used to customize Next.js behavior.
Question 20: What does SSR stand for in Next.js?
- Static Site Rendering
- Server Side Rendering
- Secure Site Rendering
- System Side Rendering
Explanation: SSR means Server Side Rendering.
Question 21: Which command is used to build a Next.js app for production?
- npm run dev
- next start
- npm run build
- npm install
Explanation: npm run build creates an optimized production build.
Question 22: What is the purpose of next/head?
- To add scripts
- To manage API calls
- To modify the HTML head
- To manage routing
Explanation: next/head allows modifying meta tags and title.
Question 23: Which feature helps Next.js improve SEO?
- Client-only rendering
- Server-side rendering
- Inline styling
- Local storage
Explanation: Server-side rendering helps search engines index pages.
Question 24: What happens when you add a new file in the pages folder?
- It creates a new component only
- It creates a new API
- It automatically becomes a route
- It causes an error
Explanation: Each file in pages maps to a route.
Question 25: Which extension is commonly used for Next.js pages?
Explanation: Next.js pages are usually written in .js or .jsx.
Question 26: What does hydration mean in Next.js?
- Fetching data from API
- Adding CSS styles
- Attaching React to server-rendered HTML
- Deploying the app
Explanation: Hydration connects React to server-rendered HTML.
Question 27: Which company created Next.js?
- Google
- Meta
- Vercel
- Microsoft
Explanation: Next.js was created by Vercel.
Question 28: What is the main benefit of file-based routing?
- Manual configuration
- Better security
- Automatic route creation
- Smaller bundle size
Explanation: File-based routing automatically creates routes.
Question 29: Which lifecycle is commonly used for data fetching in Next.js pages?
- componentDidMount
- useEffect
- getStaticProps or getServerSideProps
- render
Explanation: Next.js provides dedicated data-fetching functions.
Question 30: Which environment is Next.js suitable for?
- Frontend only
- Backend only
- Full-stack applications
- Mobile apps only
Explanation: Next.js supports both frontend and backend features.
Question 31: What is the purpose of next/router?
- Styling pages
- Managing API calls
- Handling navigation programmatically
- Optimizing images
Explanation: next/router allows programmatic navigation.
Question 32: Which folder is NOT required in a basic Next.js app?
- pages
- public
- node_modules
- controllers
Explanation: controllers is not part of a default Next.js structure.
Question 33: What type of application is Next.js best suited for?
- Static and dynamic web apps
- Desktop applications
- Embedded systems
- CLI tools
Explanation: Next.js is designed for modern web applications.
Question 34: Which command is used to start Next.js in production mode?
- npm run dev
- next start
- npm install
- next build
Explanation: next start runs the production server.
Question 35: What is automatic code splitting in Next.js?
- Splitting CSS files
- Loading only required JavaScript per page
- Removing unused code
- Compressing images
Explanation: Next.js loads only the JavaScript needed for each page.
Question 36: Which feature improves performance in Next.js?
- Image optimization
- Manual routing
- Inline scripts
- Hard reloads
Explanation: Image optimization improves performance significantly.
Question 37: Which hook is commonly used for side effects in Next.js components?
- useState
- useEffect
- useRouter
- useMemo
Explanation: useEffect handles side effects in React and Next.js.
Question 38: What is the role of React in Next.js?
- It replaces Next.js
- It provides UI components
- It handles database operations
- It manages servers
Explanation: React is used for building the UI in Next.js.
Question 39: Which file runs before rendering every page?
- _document.js
- _app.js
- index.js
- layout.js
Explanation: _app.js wraps all pages in Next.js.
Question 40: Which statement best describes Next.js?
- A CSS framework
- A backend-only framework
- A React framework for production apps
- A database tool
Explanation: Next.js is a production-ready React framework.
Question 41: What is the main advantage of SSR in Next.js?
- Faster builds
- Better SEO and initial load
- Smaller images
- Simpler syntax
Explanation: SSR improves SEO and first-page load time.
Question 42: Which keyword is used to export a page component?
- module.exports
- export default
- exports.page
- default export
Explanation: Pages must be exported as default exports.
Question 43: What does Next.js use instead of react-router?
- Manual routing
- File-based routing
- Hash routing
- Memory routing
Explanation: Next.js uses file-based routing instead of react-router.
Question 44: Which folder contains third-party dependencies?
- public
- pages
- node_modules
- lib
Explanation: node_modules stores installed dependencies.
Question 45: What is incremental static regeneration related to?
- Client-side rendering
- Updating static pages after build
- API routes
- Image loading
Explanation: ISR allows updating static pages after deployment.
Question 46: Which statement about Next.js is true?
- It cannot be used with APIs
- It only supports SSR
- It supports both frontend and backend logic
- It replaces React completely
Explanation: Next.js supports full-stack development.
Question 47: What is the main goal of Next.js?
- Simplify React app development for production
- Replace JavaScript
- Build mobile apps
- Create databases
Explanation: Next.js aims to simplify building production-ready React apps.