![]() |
VOOZH | about |
Navigating between pages in Next.js is smooth and optimized for performance, with the help of its built-in routing capabilities. The framework utilizes client-side navigation and dynamic routing to ensure fast, smooth transitions and an enhanced user experience.
In Next.js, navigation is primarily handled through the <Link> component from next/link, which enables client-side routing. This avoids full page reloads and speeds up page transitions. For programmatic navigation, the useRouter hook from next/router allows navigation based on user actions or logic.
To provide the navigation between pages we will:
npx create-next-app my-appcd my-appThe updated dependencies in package.json file will look like:
"dependencies": {
"bootstrap": "^5.3.3",
"next": "14.1.3",
"react": "^18"
}
Example: Implementation to navigate between pages in a Next.js application
Output: