Home / Blog / Engineering
Engineering

Getting Started with Next.js 15

Learn how to build modern web applications with Next.js 15 and the App Router

Yudi Nugraha
March 15, 2024
2 min read
Featured

Getting Started with Next.js 15

Next.js 15 brings powerful new features for building modern web applications. In this guide, we'll explore the fundamentals and best practices.

Why Next.js?

Next.js is a React framework that provides:

  • Server-side rendering (SSR)
  • Static site generation (SSG)
  • API routes
  • Built-in optimization
  • Great developer experience
  • Installation

    Getting started is simple:

    npx create-next-app@latest my-app
    cd my-app
    npm run dev
    

    App Router

    The new App Router uses React Server Components by default:

    // app/page.tsx
    export default function Home() {
      return (
        <main>
          <h1>Welcome to Next.js 15</h1>
        </main>
      );
    }
    

    Key Features

    1. File-based Routing

    Create routes by adding files to the app directory:

  • app/page.tsx/
  • app/about/page.tsx/about
  • app/blog/[slug]/page.tsx/blog/:slug
  • 2. Layouts

    Share UI between routes with layouts:

    // app/layout.tsx
    export default function RootLayout({
      children,
    }: {
      children: React.ReactNode;
    }) {
      return (
        <html>
          <body>
            <nav>Navigation</nav>
            {children}
            <footer>Footer</footer>
          </body>
        </html>
      );
    }
    

    3. Data Fetching

    Fetch data directly in components:

    async function getData() {
      const res = await fetch('https://api.example.com/data');
      return res.json();
    }
    
    export default async function Page() {
      const data = await getData();
      return <div>{data.title}</div>;
    }
    

    Conclusion

    Next.js 15 provides everything you need to build production-ready web applications. Start building today!

    Tags

    Next.jsReactWeb Development
    Y

    Yudi Nugraha

    Software Engineer | Builder

    More Articles

    Explore more articles on similar topics

    View All Articles