Q101. How do you create a dynamic route in Next.js?
In the pages directory, you can add bracket syntax to create dynamic routes: ```jsx pages/posts/[id].js → /posts/1, /posts/2, etc. pages/[username]/settings.js → /foo/set...
Technical Question Bank · Peer-Reviewed
Search and filter frequently asked interview questions across technical, programming, and behavioral domains. Tailor your interview preparation by difficulty for freshers or experienced developers (188 available).
In the pages directory, you can add bracket syntax to create dynamic routes: ```jsx pages/posts/[id].js → /posts/1, /posts/2, etc. pages/[username]/settings.js → /foo/set...
A catch-all segment allows you to match multiple segments in a dynamic route. It is defined using `[[...param]]` syntax. This allows you to create routes that can match m...
In the Next.js Pages Router, **`pages/_app.js`** (or `_app.tsx`) is the top-level root component that wraps every single page in the application during rendering: ### Key...
In the Next.js Pages Router, **`pages/_document.js`** (or `_document.tsx`) allows developers to augment the server-rendered HTML document skeleton (``, ``, ``). ### Key C...
While both are root-level files in the Next.js Pages Router, they operate at fundamentally different layers: | Dimension | `_app.js` | `_document.js` | | :--- | :--- | :-...
In the Next.js Pages Router, **`pages/_error.js`** (or `_error.tsx`) is a fallback error page rendered whenever an unhandled HTTP exception (such as a 500 internal server...
Creating a customized 404 Not Found page is straightforward in both Next.js routers: ### 1. In App Router (`app/` directory): Create **`app/not-found.tsx`**: ```tsx // ap...
Using getStaticProps or getServerSideProps in server side. ```jsx // getStaticProps export async function getStaticProps() { const res = await fetch("https://api.github.c...
A function that runs at build time to fetch data for a page. ```jsx export async function getStaticProps(context) { const res = await fetch(`https://...`); const data = a...
A function that runs on each request to fetch data for a page. ```jsx export async function getServerSideProps(context) { const res = await fetch(`https://...`); const da...
HireXTech uses essential storage to remember your study preferences and third-party advertising cookies via Google AdSense in compliance with GDPR. You can choose to enable essential cookies only or accept all cookies. Read our Privacy Policy.