How to create a "Hello World" in Next.js?
Josivan Ribeiro da Silva
Founder & Software Architect Hands On @ FullStackFy | Coding
Step 1: Set Up a New Next.js Project
Ensure Node.js is installed: Verify that Node.js is installed by running:
node -v
If not installed, download it from nodejs.org.
Create a new Next.js project using npx:
npx create-next-app@latest hello-world-next
This will prompt you to set up your project. Press Enter to use the default settings, or customize as needed. If npx isn’t available, install it by updating Node.js or installing globally via
npm install -g npx
Navigate to the project directory:
cd hello-world-next
Step 2: Create a Simple Page
Create a new file named index.js in the pages directory if it doesn't already exist:
// pages/index.js
export default function Home() {
return (
<div>
<h1>Hello, World!</h1>
<p>Welcome to Next.js!</p>
</div>
);
}
Step 3: Run the Development Server
Start the Next.js development server:
npm run dev
Open your browser and navigate to https://localhost:3000 to see your "Hello World" page.