HomeBlogComplete Beginner's Guide to Building Modern Web Apps with Next.js and Shadcn/UI in 2025
Tutorials & Guides
June 3, 2025
12 min read
100 views

Complete Beginner's Guide to Building Modern Web Apps with Next.js and Shadcn/UI in 2025

Learn to build modern, responsive web applications with Next.js 14+ and Shadcn/UI. Complete tutorial with code examples, best practices, and SEO optimization.

Aditya Sanehi
Aditya Sanehi
Author
Share:
Next.jsShadcn/UIReactTypeScriptTutorial
Complete Beginner's Guide to Building Modern Web Apps with Next.js and Shadcn/UI in 2025

Building modern, responsive web applications has never been easier thanks to powerful frameworks like Next.js and component libraries like Shadcn/UI. This comprehensive tutorial will walk you through creating your first project using these cutting-edge technologies, perfect for developers looking to build professional-grade applications quickly and efficiently.

What You'll Learn

By the end of this tutorial, you'll have:

  • Set up a complete Next.js 14 project with App Router
  • Integrated Shadcn/UI components for stunning interfaces
  • Built a responsive dashboard with modern UI components
  • Implemented dark/light mode functionality
  • Optimized your app for performance and SEO

Prerequisites

Before we begin, make sure you have:

  • Node.js 18.17 or later installed
  • Basic knowledge of React and JavaScript
  • A code editor (VS Code recommended)
  • Terminal/command line access

Why Next.js and Shadcn/UI?

Next.js Benefits:

  • Server-Side Rendering (SSR) for better SEO and performance
  • App Router for intuitive file-based routing
  • Built-in optimization for images, fonts, and JavaScript
  • Full-stack capabilities with API routes
  • Excellent developer experience with hot reloading

Shadcn/UI Advantages:

  • Copy-paste components - no package dependencies
  • Fully customizable with Tailwind CSS
  • Accessible by default following ARIA guidelines
  • Modern design system with consistent styling
  • TypeScript ready for better development experience

Step 1: Setting Up Your Next.js Project

Let's start by creating a new Next.js project with the App Router:

npx create-next-app@latest my-dashboard-app --typescript --tailwind --eslint --app cd my-dashboard-app

This command creates a new Next.js project with:

  • TypeScript for better code quality
  • Tailwind CSS for styling
  • ESLint for code linting
  • App Router (the latest routing system)

Step 2: Installing and Configuring Shadcn/UI

Now let's add Shadcn/UI to our project:

npx shadcn-ui@latest init

You'll be prompted with several configuration options. Here are the recommended settings:

✔ Which style would you like to use? › Default
✔ Which color would you like to use as base color? › Slate
✔ Where is your global CSS file? › app/globals.css
✔ Would you like to use CSS variables for colors? › yes
✔ Where is your tailwind.config.js located? › tailwind.config.js
✔ Configure the import alias for components? › @/components
✔ Configure the import alias for utils? › @/lib/utils

Step 3: Adding Essential Components

Let's add some commonly used Shadcn/UI components:

npx shadcn-ui@latest add button card input label npx shadcn-ui@latest add navigation-menu dropdown-menu npx shadcn-ui@latest add avatar badge sheet

These components will give us a solid foundation for building our dashboard.

Step 4: Creating a Modern Dashboard Layout

Let's create a responsive dashboard layout. First, create a new component file:

// components/dashboard-layout.tsx import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { Badge } from "@/components/ui/badge" import { Bell, Home, Settings, Users, BarChart3, Menu } from "lucide-react" export default function DashboardLayout() { return ( <div className="min-h-screen bg-gray-50 dark:bg-gray-900"> {/* Navigation Sidebar */} <div className="fixed inset-y-0 left-0 z-50 w-64 bg-white dark:bg-gray-800 shadow-lg"> <div className="flex h-16 items-center justify-between px-6"> <h1 className="text-xl font-bold text-gray-900 dark:text-white"> Dashboard </h1> <Button variant="ghost" size="sm"> <Menu className="h-4 w-4" /> </Button> </div> <nav className="mt-8 space-y-2 px-4"> {[ { icon: Home, label: "Home", active: true }, { icon: Users, label: "Users" }, { icon: BarChart3, label: "Analytics" }, { icon: Settings, label: "Settings" }, ].map((item) => ( <Button key={item.label} variant={item.active ? "default" : "ghost"} className="w-full justify-start" > <item.icon className="mr-3 h-4 w-4" /> {item.label} </Button> ))} </nav> </div> {/* Main Content */} <div className="pl-64"> {/* Top Header */} <header className="bg-white dark:bg-gray-800 shadow-sm"> <div className="flex h-16 items-center justify-between px-6"> <h2 className="text-lg font-semibold text-gray-900 dark:text-white"> Welcome back, John! </h2> <div className="flex items-center space-x-4"> <Button variant="ghost" size="sm"> <Bell className="h-4 w-4" /> </Button> <Avatar> <AvatarImage src="/placeholder-avatar.jpg" /> <AvatarFallback>JD</AvatarFallback> </Avatar> </div> </div> </header> {/* Dashboard Content */} <main className="p-6"> <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3"> {/* Stats Cards */} <Card> <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> <CardTitle className="text-sm font-medium">Total Users</CardTitle> <Users className="h-4 w-4 text-muted-foreground" /> </CardHeader> <CardContent> <div className="text-2xl font-bold">2,543</div> <p className="text-xs text-muted-foreground"> +12% from last month </p> </CardContent> </Card> <Card> <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> <CardTitle className="text-sm font-medium">Revenue</CardTitle> <BarChart3 className="h-4 w-4 text-muted-foreground" /> </CardHeader> <CardContent> <div className="text-2xl font-bold">$45,231</div> <p className="text-xs text-muted-foreground"> +8% from last month </p> </CardContent> </Card> <Card> <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> <CardTitle className="text-sm font-medium">Active Projects</CardTitle> <Badge variant="secondary">12</Badge> </CardHeader> <CardContent> <div className="text-2xl font-bold">12</div> <p className="text-xs text-muted-foreground"> 3 completed this week </p> </CardContent> </Card> </div> {/* Recent Activity */} <Card className="mt-6"> <CardHeader> <CardTitle>Recent Activity</CardTitle> <CardDescription> Your latest project updates and notifications </CardDescription> </CardHeader> <CardContent> <div className="space-y-4"> {[ { action: "New user registered", time: "2 minutes ago" }, { action: "Project Alpha completed", time: "1 hour ago" }, { action: "Database backup completed", time: "3 hours ago" }, ].map((activity, index) => ( <div key={index} className="flex items-center justify-between"> <span className="text-sm">{activity.action}</span> <span className="text-xs text-muted-foreground">{activity.time}</span> </div> ))} </div> </CardContent> </Card> </main> </div> </div> ) }

Step 5: Implementing Dark Mode Support

Shadcn/UI comes with built-in dark mode support. Let's add a theme toggle:

npx shadcn-ui@latest add dropdown-menu

Create a theme provider component:

// components/theme-provider.tsx "use client" import * as React from "react" import { ThemeProvider as NextThemesProvider } from "next-themes" import { type ThemeProviderProps } from "next-themes/dist/types" export function ThemeProvider({ children, ...props }: ThemeProviderProps) { return <NextThemesProvider {...props}>{children}</NextThemesProvider> }

Install the next-themes package:

npm install next-themes

Add the theme provider to your root layout:

// app/layout.tsx import { ThemeProvider } from "@/components/theme-provider" export default function RootLayout({ children, }: { children: React.ReactNode }) { return ( <html lang="en" suppressHydrationWarning> <body> <ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange > {children} </ThemeProvider> </body> </html> ) }

Step 6: Adding Your Dashboard to the Home Page

Update your main page to use the dashboard:

// app/page.tsx import DashboardLayout from "@/components/dashboard-layout" export default function Home() { return <DashboardLayout /> }

Step 7: Performance Optimization

Next.js provides excellent built-in optimizations, but here are some additional tips:

Image Optimization

Always use Next.js Image component for better performance:

import Image from 'next/image' // In your component <Image src="/your-image.jpg" alt="Description" width={500} height={300} priority // For above-the-fold images />

Font Optimization

Use Next.js font optimization in your layout:

import { Inter } from 'next/font/google' const inter = Inter({ subsets: ['latin'] }) export default function RootLayout({ children, }: { children: React.ReactNode }) { return ( <html lang="en" className={inter.className}> <body>{children}</body> </html> ) }

Step 8: SEO Optimization

Add proper metadata to your pages:

// app/layout.tsx import type { Metadata } from 'next' export const metadata: Metadata = { title: 'Modern Dashboard - Built with Next.js and Shadcn/UI', description: 'A responsive, modern dashboard built with Next.js 14 and Shadcn/UI components', keywords: ['Next.js', 'Shadcn/UI', 'Dashboard', 'React', 'TypeScript'], authors: [{ name: 'Your Name' }], openGraph: { title: 'Modern Dashboard App', description: 'Professional dashboard built with modern web technologies', type: 'website', }, }

Step 9: Running Your Application

Start your development server:

npm run dev

Visit http://localhost:3000 to see your beautiful dashboard in action!

Common Troubleshooting Tips

Theme Not Working?

Make sure you've added the suppressHydrationWarning attribute to your HTML tag and properly configured the ThemeProvider.

Components Not Styling Correctly?

Verify that your tailwind.config.js includes the Shadcn/UI configuration and that you've imported the global CSS file.

TypeScript Errors?

Ensure all component imports are correct and that you've installed all necessary dependencies.

Next Steps and Advanced Features

Now that you have a basic dashboard, consider adding:

  1. Authentication with NextAuth.js
  2. Database integration with Prisma
  3. API routes for backend functionality
  4. Form handling with React Hook Form
  5. Data visualization with Chart.js or Recharts
  6. Real-time updates with WebSockets

Best Practices for Production

When deploying your application:

  1. Enable production optimizations in your build process
  2. Use environment variables for sensitive data
  3. Implement proper error handling and logging
  4. Add loading states for better user experience
  5. Optimize your bundle size with dynamic imports
  6. Set up monitoring with tools like Vercel Analytics

Conclusion

You've successfully built a modern, responsive dashboard using Next.js 14 and Shadcn/UI! This powerful combination provides:

  • Excellent performance with server-side rendering
  • Beautiful, accessible UI components that are fully customizable
  • Developer-friendly experience with TypeScript and hot reloading
  • Production-ready features including SEO optimization and dark mode

The skills you've learned in this tutorial form the foundation for building complex, professional web applications. Next.js and Shadcn/UI continue to evolve, so stay updated with their latest features and best practices.

Key Takeaways

  • Next.js 14 with App Router provides powerful routing and rendering capabilities
  • Shadcn/UI offers copy-paste components that are highly customizable
  • Proper project structure and configuration are crucial for maintainability
  • Performance and SEO optimization should be considered from the start
  • Modern web development focuses on developer experience and user experience equally

Ready to build your next amazing web application? Start experimenting with different Shadcn/UI components and explore the vast ecosystem of Next.js plugins and tools!


Want to learn more advanced Next.js techniques? Check out our other tutorials on API development, database integration, and deployment strategies. Follow us for more web development insights and tutorials!

Last updated: July 14, 2025

About the Author

Aditya Sanehi

Aditya Sanehi

Founder @ OnlyTools, delivering scalable APIs and automation tools exclusively for modern, growth-focused businesses.

Stay Connected

Enjoyed This Article?

Subscribe to our newsletter for more insights on automation, API development, and business technology trends.

Stay Updated

Get weekly insights delivered to your inbox.

Share this article: