Building Portfolio in Next.js
Tutorials
Building Portfolio in Next.js

By Subash Maharjan


Chapters
  • Chapter 1

    Introduction

  • Chapter 2

    Project Architecture

  • Chapter 3

    SCSS Design Tokens

  • Chapter 4

    The Hero Component

  • Chapter 5

    The MDX Content Layer

  • Chapter 6

    Syntax Highlighting & Project Filters

  • Chapter 7

    Smooth Layout Transitions

  • Chapter 8

    Modern Contact Forms

  • Chapter 9

    SEO & Deployment

  • Chapter 10

    Lighthouse Performance & Blogging

  • Chapter 11

    Interactive Playgrounds & Subscriptions

  • Chapter 12

    Dynamic Social Previews & Launch

  • Chapter 13

    Project Summary for Recruiters

  • building portfolio in nextjs

    The Hero Component

    Chapter 4

    2 min read

    On this page
    1. Hero Styling (`Hero.module.scss`)2. React Implementation (Hero.tsx)3. Usage in the Homepage
    Company LogoSubash
    HOMEABOUTPORTFOLIOCONTENTSCONTACT

    The Hero Section is the most critical part of your portfolio. We'll build it to be fully responsive and utilize our global $color-crimson variable and @include mobile mixin.

    1. Hero Styling (Hero.module.scss)

    Because we configured prependData in next.config.mjs, we don't need to import our variables or mixins here.

    .hero {
      min-height: 80vh;
      display: flex;
      flex-direction: column;
      justify-content: center;
      padding: $spacing-lg;
     
      @include mobile {
        padding: $spacing-md;
        text-align: center;
      }
     
      .title {
        font-size: 4rem;
        font-weight: 800;
        margin-bottom: $spacing-sm;
     
        span {
          color: $color-crimson;
        }
     
        @include mobile {
          font-size: 2.5rem;
        }
      }
     
      .description {
        max-width: 600px;
        font-size: 1.2rem;
        line-height: 1.6;
        opacity: 0.8;
      }
     
      .cta {
        margin-top: $spacing-md;
        
        @include mobile {
          width: 100%;
        }
      }
    }

    2. React Implementation (Hero.tsx)

    We'll use Next.js Image for performance and standard HTML for the structure.

    // src/components/layout/Hero.tsx
    import styles from './Hero.module.scss';
    import Link from 'next/link';
     
    interface HeroProps {
      name: string;
      role: string;
      description: string;
    }
     
    export default function Hero({ name, role, description }: HeroProps) {
      return (
        <section className={styles.hero}>
          <h1 className={styles.title}>
            Hi, I'm <span>{name}</span>
          </h1>
          <h2 className={styles.role}>{role}</h2>
          <p className={styles.description}>{description}</p>
          
          <div className={styles.cta}>
            <Link href="/portfolio" className="btn-primary">
              View My Work
            </Link>
          </div>
        </section>
      );
    }

    3. Usage in the Homepage

    Now, simply drop the component into your main page. Next.js will handle the Critical CSS extraction automatically.

    // src/app/page.tsx
    import Hero from '@/components/layout/Hero';
     
    export default function HomePage() {
      return (
        <main>
          <Hero 
            name="Alex"
            role="Full Stack Developer"
            description="I build high-performance web applications using Next.js and SCSS."
          />
          {/* Other sections like Projects or Skills go here */}
        </main>
      );
    }

    Pro-Tip: Framer Motion Integration

    To add an entry animation, you can wrap your hero content in a <motion.section> from Framer Motion. Since animations require browser APIs, you must include the "use client"; directive at the top of your component file.

    "use client"; // Required for Framer Motion
    import { motion } from 'framer-motion';
    import styles from './Hero.module.scss';
     
    export default function Hero() {
      return (
        <motion.section 
          initial={{ opacity: 0, y: 20 }}
          animate={{ opacity: 1, y: 0 }}
          transition={{ duration: 0.5 }}
          className={styles.hero}
        >
          {/* Your Content Here */}
          <h1>Welcome to my Portfolio</h1>
        </motion.section>
      );
    }
    HOME
    ABOUT
    PORTFOLIO
    CONTENTS
    CONTACT

    © 2026Subash Maharjan™

    Made byHudeoworks Design