šŸ’” Key Takeaways

⚔ Project Setup: Use create-next-app with TypeScript or JavaScript.
šŸ—ļø App Structure: App Router (app/) for modern nested layouts; page.tsx per route.
🌐 Routing: Pages map to URLs automatically; layouts wrap pages globally or nested.
šŸš€ Dev & Prod: next dev for development, next build && next start for production.
🧩 Best Practices: Global CSS in styles/, shared UI in layout.tsx.

1ļøāƒ£ Create a New App

  • Initialize with TypeScript or JavaScript
  • Optionally add Tailwind CSS
  • Choose App Router (modern) or Pages Router
npx create-next-app@latest my-app
# TypeScript version
npx create-next-app@latest my-app --typescript

2ļøāƒ£ Start the Dev Server

  • Navigate to project folder
  • Run dev server on http://localhost:3000
cd my-app
npm run dev
# or
yarn dev

3ļøāƒ£ Folder Structure (App Router)

  • app/ → pages and layouts
  • public/ → static assets
  • styles/ → global CSS or Tailwind files
  • next.config.js → project configuration
my-app/
ā”œā”€ā”€ app/
│   ā”œā”€ā”€ page.tsx         # Home page
│   ā”œā”€ā”€ layout.tsx       # Root layout
│   └── about/page.tsx   # Nested route
ā”œā”€ā”€ public/
ā”œā”€ā”€ styles/
ā”œā”€ā”€ next.config.js

4ļøāƒ£ Add a New Route

  • Create a folder under app/ for route
  • Add page.tsx for the route component
// app/about/page.tsx
export default function About() {
  return <h1>About Page</h1>;
}
// Accessible at /about

5ļøāƒ£ Add a Global Layout

  • Wrap pages with shared UI like header/footer
  • Layouts support nested routes
// app/layout.tsx
export default function RootLayout({ children }) {
  return (
    <html>
      <body>{children}</body>
    </html>
  );
}

6ļøāƒ£ Build and Start Production

  • Create production-ready build
  • Start server to serve optimized pages
npm run build
npm run start

7ļøāƒ£ Quick Tips

  • Use next dev for development
  • Place global CSS in app/styles/globals.css
  • Use page.tsx for individual routes
  • Prefer App Router for server components and nested layouts

Disclaimer: The information provided on this website is for educational and informational purposes only. Health-related content is not intended to serve as medical advice, diagnosis, or treatment recommendations and should not replace consultation with qualified healthcare professionals. Financial content is for educational purposes only and does not constitute financial advice, investment recommendations, or professional financial planning services. Always consult with licensed healthcare providers for medical concerns and qualified financial advisors for personalized financial guidance.