Recap: Routing
Part of the Next.js Essentials section of Coddy's React journey — lesson 10 of 47.
Challenge
MediumChapter recap: turn a one-page app into a small site, using everything from this chapter.
- Create
app/about/page.jsx. Default-export a component that returns an<h1>withid="about-title"and the exact textAbout us. - In
app/page.jsx, importLinkfromnext/linkand add a link to/aboutwithid="to-about". - Create the dynamic route
app/menu/[slug]/page.jsx: anasynccomponent that awaitsparamsand renders the matchedsluginside an<h1>withid="dish".
The tests click your link, then visit two different dishes and expect two different headings.
Try it yourself
import './globals.css';
export const metadata = {
title: 'My App',
};
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
{children}
</body>
</html>
);
}All lessons in Next.js Essentials
2Routing & Links
Folders Are RoutesNested RoutesLinking PagesDynamic RoutesNot Found PagesRecap: Routing