0
0
NextJSframework~5 mins

Matching paths with config in NextJS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does 'matching paths with config' mean in Next.js routing?
It means defining rules or patterns in a configuration to decide how URLs (paths) are handled or matched to specific pages or components.
Click to reveal answer
beginner
How do you define a dynamic route in Next.js using file system routing?
You create a file or folder with square brackets, like [id].js, to match any value in that part of the URL path.
Click to reveal answer
intermediate
What is the purpose of a next.config.js file in Next.js?
It lets you customize Next.js behavior, including how paths are matched or rewritten before rendering pages.
Click to reveal answer
intermediate
How can you rewrite paths in Next.js without changing the URL shown to users?
By using the rewrites() function in next.config.js to map one path to another internally.
Click to reveal answer
intermediate
What is the difference between a rewrite and a redirect in Next.js path config?
A rewrite changes the path internally without changing the URL in the browser. A redirect changes the URL the user sees and navigates to.
Click to reveal answer
In Next.js, how do you create a route that matches any user ID in the URL?
AUse a regular expression in <code>next.config.js</code>
BAdd a route in <code>routes.js</code>
CCreate a file named <code>[userId].js</code> inside the pages folder
DUse a query parameter in the URL
What does the rewrites() function in next.config.js do?
AChanges the URL shown in the browser
BMaps one path to another internally without changing the URL
CRedirects users to a new URL
DDeletes unused routes
Which file is used to configure path matching rules in Next.js?
Anext.config.js
Bpackage.json
Croutes.config.js
Dserver.js
What happens if you define a redirect in Next.js path config?
AThe URL in the browser changes to the new path
BThe URL stays the same but content changes
CThe page reloads without changing URL
DNothing happens
How can you match multiple paths with one config rule in Next.js?
ACreate a separate config file for each path
BWrite multiple <code>if</code> statements in <code>next.config.js</code>
CUse CSS selectors
DUse wildcards or dynamic segments in file names
Explain how Next.js matches URL paths to pages using file system routing and config.
Think about how URLs map to files and how config can change that mapping.
You got /3 concepts.
    Describe how you would use next.config.js to rewrite a path internally without changing the browser URL.
    Focus on internal path mapping versus user-visible URL changes.
    You got /3 concepts.