Muhammad SharjeelSenior Software Engineer

Islamabad · --:--:--


Getting Started with Next.js: Structure, Tips & Deployment

A developer-friendly introduction to Next.js — learn how to scaffold projects, understand folder structure, configure features, and deploy to Vercel seamlessly.

Next.js is a powerful React-based framework that enables developers to build fast, SEO-friendly web applications with minimal setup. Whether you're building a static marketing page, a full-stack SaaS product, or a blog — Next.js handles routing, rendering modes, and performance out of the box.

Why Choose Next.js?

  • File-based routing: No need for React Router. Just drop a file in /app or /pages and it becomes a route.
  • Server-side rendering & static generation: Easily switch between SSR, SSG, or client-side rendering.
  • Built-in API routes: Create full-stack apps without needing a separate backend.
  • Seamless Vercel deployment: Optimized for Vercel hosting.

Project Setup

Let’s create a new Next.js app using the App Router approach (recommended in Next.js 13+).

npx create-next-app@latest my-nextjs-app --experimental-app

After the CLI prompts, your project will be initialized with the following folder structure:

Project Structure Overview

.
      ├── app/                // App Router entrypoint
      │   ├── layout.tsx      // Root layout (wrapping component)
      │   ├── page.tsx        // Homepage ("/")
      │   └── (routes)/       // Sub-routes as directories
      ├── components/         // Shared UI components
      ├── public/             // Static assets (e.g. images, fonts)
      ├── styles/             // Tailwind/global styles
      ├── lib/                // Utilities, helper functions
      ├── .env.local          // Environment variables
      ├── tailwind.config.ts  // Tailwind configuration
      ├── next.config.js      // Framework-level config
      └── package.json

This modular layout promotes separation of concerns and scalability.


Adding Tailwind CSS

Tailwind helps you build modern UIs rapidly. To install it:

npm install -D tailwindcss postcss autoprefixer
      npx tailwindcss init -p

Update your tailwind.config.ts to include:

"content": ["./app/**/*.{js,ts,jsx,tsx}", "./components/**/*.{js,ts,jsx,tsx}"]

And in your global CSS file (usually globals.css):

@tailwind base;
      @tailwind components;
      @tailwind utilities;

Routing with the App Router

Next.js App Router introduces nested layouts, dynamic routing, and server components by default.

Create a route:

// app/about/page.tsx
      export default function AboutPage() {
        return <h1>About Me</h1>
      }

This will now be available at /about.

Nested Layouts:

// app/dashboard/layout.tsx
      export default function DashboardLayout({ children }) {
        return (
          <div>
            <Sidebar />
            {children}
          </div>
        )
      }

This layout wraps all routes under /dashboard.


Environment Configuration

Create a .env.local file in your root for environment-specific settings:

NEXT_PUBLIC_API_BASE_URL=https://api.example.com
NEXT_PUBLIC_ENV=development

Access these with process.env.NEXT_PUBLIC_* in your codebase.


Useful Libraries to Add

  • clsx / tailwind-merge – Handle conditional classNames.
  • shadcn/ui – Prebuilt headless UI components with Tailwind.
  • framer-motion – For page transitions and motion effects.
  • zod – For schema validation in forms or APIs.

Deploying to Vercel (Free Hosting)

  1. Push your code to GitHub.
  2. Go to vercel.com and sign in.
  3. Click “New Project” and import your GitHub repo.
  4. Vercel auto-detects the framework and deploys your app instantly.

Bonus: You get previews on every commit and custom domains. You can also add environment variables from the Vercel dashboard.


Final Thoughts

Next.js offers a scalable foundation whether you're just starting out or building enterprise-level applications. Understanding the project structure and deployment process will help you ship better, faster.

If you're new to the ecosystem, start small — build a portfolio, a blog, or a dashboard UI. The tooling is designed to grow with you.

Useful Links

esc
HomeThe hero, the system map and selected workPageWorkAll 6 projects, each with a glimpse of its interfacePageAboutExperience, how I work and the stack I usePageWriting12 posts on engineering, AI and designPageGet in touchContact me by email or hire me on UpworkSection
Alara CodeTurns a client brief into a complete, human-approved software delivery pack.ProjectPolyXIdentity, tenancy and access platform shared by every product in the company.ProjectPolyX SDKTypeScript auth SDK on npm that puts the platform behind one typed client.ProjectAlara SpaceMulti-tenant team wiki that AI agents can read and write through MCP.ProjectAlara PlanProject tracker with AI meeting minutes, support intake and an MCP server.ProjectODINOmni-channel customer engagement platform on a microservices backend.Project
A portfolio that builds itself while you scrollThis site starts as a blank canvas and a swarm of cursors draws it in front of you. Here is why I wanted that, what it is made of, and everything that went wrong on the way.8 min readUnslopping AI output with nothing but a skillYou do not need a better model to get rid of the purple gradients. You need your taste written down as a skill the agent loads before it touches the screen.2 min readAI Assistant Coding vs Vibe CodingAs AI becomes ubiquitous in software development, a dangerous pattern is emerging: developers blindly accepting AI suggestions without understanding the code. This 'vibe coding' approach undermines the fundamentals of being a developer. Here's why understanding code matters more than shipping it, and how to use AI as a proper assistant.8 min readHosting Multiple Domains on One Server with Docker, NGINX & SSL (DevOps for Developers)As a full-stack developer, I recently had to deploy multiple backend services on one server, each with its own domain and SSL certificate. Here's how I combined Docker, NGINX, and Certbot to build a scalable, production-grade setup — without needing a dedicated DevOps engineer.3 min readTaming CORS in a Microservices Monorepo: From Async Validation to a Unified ConfigCORS errors can be frustrating, especially in a microservices monorepo setup. This blog dives into what CORS really is, why it matters, and how I solved the CORS challenge using a shared JSON config file — establishing a single source of truth for all services.4 min readDebugging Tips for Frontend Developers (React + Next.js)Effective debugging is one of the most valuable skills for frontend developers. Here's a practical guide to debugging with logs, using the debugger keyword, troubleshooting APIs, and improving performance — with a special focus on React and Next.js.3 min readIs the ‘AI Developer’ a Threat to Jobs – or a Marketing Stunt?AI dev tools are booming — but are they replacing developers or just reshaping workflows? Here's the balanced view.3 min readUsing Docker & NGINX to Build a Suite of MicroservicesExplore how to use Docker and NGINX to containerize and orchestrate a scalable microservices suite. Includes setup tips, architecture advice, and real-world tradeoffs.3 min readGetting Started with Next.js: Structure, Tips & DeploymentA developer-friendly introduction to Next.js — learn how to scaffold projects, understand folder structure, configure features, and deploy to Vercel seamlessly.3 min readGrid Systems: The Foundation of Great UI DesignWant cleaner, more balanced layouts? A grid system brings structure, rhythm, and clarity to your UI — and Tailwind makes it easier than ever to implement.2 min readUsing Generative AI to Speed Up Creative and Dev WorkflowsFrom ChatGPT to v0.dev — here's how generative AI helps streamline UI design, prototyping, coding, and problem-solving in modern workflows.3 min readWhat Is Accessible Design and Why It MattersAccessibility isn’t a nice-to-have. It’s a necessity. Here's why accessible design matters — and how to get it right in your UI and frontend code.3 min read
GitHubgithub.com/isharjeelddNew tabLinkedInlinkedin.com/in/muhammad-sharjeel-254a48108New tabUpworkHire me for freelance workNew tab