If you are a web developer, you have probably heard of Next.js. Next.js is a lightweight JavaScript framework that is highly efficient and built to work with your three most important tools: JavaScript, CSS and HTML, to provide a fast and easy way to create next generation websites.

There are many articles published every day on how to create multi-page websites with Next.js. However, not everyone has the time to study every piece of information needed to use it. To help you learn Next.js in a simple, concise manner I decided to create a blog post about it. I’ve used Next.js to create a simple multi-page website. In this article I’ll provide you with a step-by-step guide to creating your own multi-page website with Next.js.

Next.js is an open source JavaScript framework made by the folks over at the Next.js GitHub organization. It was born as a re-write of the popular React.js library, but has since grown into a full-blown alternative to the popular Vue.js and Angular libraries. What sets Next.js apart is that it’s not just a library, it’s also a platform that offers developers a set of tools that make it easy for them to create large, complex websites.. Read more about multi page react app github and let us know what you think.

Next.js is a React framework that aids in the development of production-ready web apps. While reading this title, you could become a little perplexed. We know that React.js was created to create single-page applications (SPA). We’ll go over how to make a multi-page website with Next.js in this article.

It’s important to understand that we’re talking about making a next.js app with numerous routes rather than multiple pages in this tutorial. However, it appears to the user as though there are numerous pages.

Note: An Itnext.io post explains how to incorporate React.js into a multi-page website.

Here, we’ll establish three routes: /, /about, and /contact, each of which renders its own set of components. It seems to the user that they are opening the corresponding page for each route.

Route Page that corresponds
/ Home page
/about About this page
/contact Page of Contact

The GIF below will give you a clear picture of how this software looks and functions.

How-To-Create-A-Multi-Page-Website-With-Nextjs-%E2%86%90

Create a Next.js program.

First, we’ll use the NPX tool to construct a Next.js application. Don’t worry about NPX; it’s a tool that comes with NPM (Node Package Manager) 5.2 and higher.

So, after successfully installing Node.js, use NPX to construct a Next.js application.

next-multi-page-website npx create-next-app How-To-Create-A-Multi-Page-Website-With-Nextjs-%E2%86%90

This command will create a react application named next-multi-page-website in the next-multi-page-website project.

Now start the program by going to the project directory.

npm start next-multi-page-website

It will launch the Next application we generated with the address https://localhost:3000 in our browser window.

1627042420_658_How-To-Create-A-Multi-Page-Website-With-Nextjs-%E2%86%90

I wrote a post on how to install and set up a Next.js app on Windows 10 if you need more help with this step.

Creating route components and pages

We need to develop route components when we create a new Next.js project. When it comes to Next.js, we refer to them as pages.

In any case, these components must render when accessing the routes.

As a result, we’ll need to create three files in the pages directory: about.js, contact.js, and index.js.

Below is the whole file structure of the program we created.

How-To-Create-A-Multi-Page-Website-With-Nextjs-%E2%86%90

About this page

When you visit the /about the route, this component is displayed. It is made up of two parts: a title and a description. A CSS file was also added to style the component.

Create a about.js file in the pages directory and paste in the code below.

import pages/about.js Import styles from ‘../styles/About.module.css’; react from “react” return( export default function About()

About This Page

Lorem Ipsum is the printing and typesetting industry’s dummy text. Since the 1500s, when an unknown printer scrambled a galley of type to construct a type specimen book, Lorem Ipsum has been the industry’s standard sham text. It has stood the test of time, surviving not just five centuries but also the transition to electronic typesetting. It became popular in the 1960s when Letraset sheets featuring Lorem Ipsum passages were released, and more recently with desktop publishing tools like Aldus PageMaker that included Lorem Ipsum renditions.

) }

Create a file called About.module.css in the styles directory as well.

.container styles/About.module.css padding: 10rem; text-align: middle; font-size: 2rem; title; title; title; title; title; title; title; title; title; title; title; title; title . font-size: 1rem; line-height: 2rem; description 1627042422_930_How-To-Create-A-Multi-Page-Website-With-Nextjs-%E2%86%90

Page of Contact

Create a contact component in the pages directory to display when the /contact route is accessed.

/ import Import styles from ‘../styles/Contact.module.css’; react from “react” return( export default function Contact()

Page of Contact

  • Name:

    Lorem

  • Email: [email protected]

) }

Also included is the Contact.module.css style for the contact component.

.container styles/Contact.module.css padding: 10rem; text-align: middle; font-size: 2rem; title; title; title; title; title; title; title; title; title; title; title; title; title . border: 1px solid #dadada; border-radius:.25rem; padding: 2rem; details border: 1px solid #dadada; border-radius:.25rem; padding: 2rem; . list list-style: none; display: flex; justify-content: center; margin-bottom: 1rem; list-style: none; display: flex; justify-content: center; margin-bottom: 1rem; list-style: none; display: flex; justify-content: center . rgb(66, 66, 66); font-size: 1rem; color: rgb(66, 66, 66); font-size: 1rem; margin: 0; margin-left: 1rem; value font-size: 1rem; margin: 0; margin-right: 1rem; value font-size: 1rem; value font-size: 1re 1627042424_204_How-To-Create-A-Multi-Page-Website-With-Nextjs-%E2%86%90

Home page

When using the / route, the component we’re going to make is rendered. So there you have it, the home page.

/ import Import styles from ‘../styles/Home.module.css’ via “next/link” return (default function Home()) export (default function Home()) export (default function Home()) export (default function

Using Next.js to create a multi-page website

Home →

About →

Contact →

) }

The style file Home.module.css is also used to style the home page.

.container styles/Home.module.css flex-direction: column; justify-content: center; align-items: center; height: 100vh; min-height: 100vh; padding: 0 0.5rem; display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; .main padding: 5rem 0; flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; flex-direction: flex; flex-direction: flex; flex-direction: flex; flex-direction: flex; flex-direction: flex; flex-direction: flex; flex-dire . margin: 0; line-height: 1.15; font-size: 2rem; title; title; title; title; title; title; title; title; title; title; title; title; title; title; title; title; title; title; title; .grid display: flex; align-items: center; justify-content: center; flex-wrap: wrap; max-width: 800px; margin-top: 3rem;.grid display: flex; align-items: center; justify-content: center; flex-wrap: wrap; max-width: 800px; margin-top: 3rem; . text-align: left; color: inherit; text-decoration: none; card margin: 1rem; padding: 1.5rem; text-align: left; color: inherit; text-decoration: none; border: 1px solid #eaeaea border-radius: 10px border-radius: 10px border-radius: 10px border-radius: 10px border-radius: 10px border-radius: 10px border-radius: 10px border-radius: 10px border-radius: 10px border-radius: 10px border-radius: 10px . .card:focus,.card:active, card:hover #0070f3; #0070f3; #0070f3; #0070f3; #0070f3; #0070f3; #0070f3; #0070f3; #0070 h2.card font-weight: 1.5rem; font-weight: 1.5rem; font-weight: 1.5rem; font-weight: 1.5rem RT @media (max-width: 600px) width: 100%; flex-direction: column;.grid 1627042425_404_How-To-Create-A-Multi-Page-Website-With-Nextjs-%E2%86%90

Add some international flair.

We can create a CSS file in the styles directory and import it from the _app.js file to add global CSS styles.

/ html, body/styles/global.css -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-s an inherit; text-decoration: none; a color: inherit; a color: inherit; a color: inherit; a color: inherit; a color: inherit; * / pages/ app.js import ‘../styles/globals.css’ function MyApp(Component, pageProps) function MyApp(Component, pageProps) function MyApp(Component, pageProps) function MyApp(Component, pageProps) function MyApp(Component, pageProps) function MyApp(Component, pageProps) function MyApp(Component, pageProps) function MyApp return default MyApp export

Codesandbox

To see the live app, go to the CodeSandbox link.

GitHub

You can always clone this project from the GitHub repository.

https://github.com/syamjayaraj/next-multi-page-website

Summary

So, in this article, we spoke about how to make a multi-page website with Next.js. It is a multi-component website that functions similarly to a multi-page website. For reference, I also added the URL to the GitHub repository where you can grab the entire project.

As an example:

As if Loading…

This could be interesting to you.

One of the common problems web developers face is creating large multi-page websites, especially when they need to dynamically generate content. The key to solving this problem is to use equal-width content containers on each page and let Next.js take care of the rest.. Read more about next-js examples and let us know what you think.

This article broadly covered the following related topics:

  • next js tutorial
  • next js monorepo example
  • next js nested dynamic routes
  • next js dynamic routing not working
  • next js monorepo typescript
You May Also Like

Minecraft Premium Account for Free – Is it Possible to Get?

I have been searching for a Minecraft premium account for free. I’m…

Instructions configure Work Document on Sophos Container Policy For Android Mobile. –

Sophos Container Policy for Android or “Sophos” is a new mobile security…

PHP contact form with Google reCaptcha

The Google reCaptcha is a security system that uses a test to…

Simple to use swipe gestures for an Android RecyclerView

Android motion scan RecyclerView Easy to use swipe gestures for Android RecyclerView.…