Before moving to project setup, make sure you understand the following foundations.
HTML defines the structure and meaning of a webpage.
<main>
<h1>My Store</h1>
<p>Discover our products.</p>
<a href="/products">View products</a>
</main>Learn semantic elements such as main, header, nav, section, article, form and button.
Semantic HTML helps with accessibility, maintainability and search engine understanding.
CSS controls presentation and layout.
css
.product-card {
padding: 1rem;
border: 1px solid #ddd;
border-radius: 0.75rem;
}
.product-card h2 {
margin-top: 0;
}You should understand:
JavaScript provides application logic and interactivity.
You should be comfortable with:
const, let, variables and data types.async and await.try and catch.fetch.Example of asynchronous JavaScript:
js
async function getProducts() {
try {
const response = await fetch(
"https://api.example.com/products"
);
if (!response.ok) {
throw new Error("Request failed");
}
return await response.json();
} catch (error) {
console.error("Could not fetch products", error);
return [];
}
}This is ordinary JavaScript and can be adapted for browser or server use. In production, handle failures according to the needs of your application rather than silently treating every error as an empty result.
Before learning Next.js, understand these React concepts:
useState.useEffect.Example:
tsx
"use client";
import { useState } from "react";
export default function Greeting() {
const [name, setName] = useState("");
return (
<section>
<label htmlFor="name">Your name</label>
<input
id="name"
value={name}
onChange={(event) => setName(event.target.value)}
placeholder="Enter your name"
/>
<p>
{name ? `Hello, ${name}!` : "Enter your name to begin."}
</p>
</section>
);
}This example uses React state and a controlled input. In the App Router, it needs to be a Client Component because it uses useState and an event handler.
app/ directory and supports Server Components, nested layouts, streaming and route-level loading UI.pages/ directory and includes APIs such as getStaticProps and getServerSideProps.