DevGrade

DevGrade React Badge Documentation

Integrate verified developer skill badges into your React portfolio with our easy-to-use component library.

Installation

Get started by installing the DevGrade React package:

Installation

Install the DevGrade Badge package via npm:

npm install devgrade-badge

Basic Usage

Import and use the DevGradeBadge component with your GitHub username:

Basic Usage

Import and use the DevGradeBadge component in your React application:

import { DevGradeBadge } from 'devgrade-badge';

function Portfolio() {
  return (
    <div>
      <DevGradeBadge username="your-username" />
    </div>
  );
}

Badge Variants

Choose from three different badge styles to match your design:

Compact Variant

Perfect for headers, sidebars, or anywhere space is limited.

<DevGradeBadge
  variant="compact"
  username="your-username"
  dark={false}
  roundness="lg"
/>

Detailed Variant

Full-featured badge showing all metrics with progress bars.

<DevGradeBadge
  variant="detailed"
  username="your-username"
  dark={false}
  roundness="xl"
/>

Minimal Variant

Clean, inline badge for seamless portfolio integration.

<DevGradeBadge
  variant="minimal"
  username="your-username"
  dark={false}
  roundness="sm"
/>

Customization

Full TypeScript interface showing all available props:

Customization Options

All available props for the DevGradeBadge component:

interface DevGradeBadgeProps {
  username: string;           // Required: DevGrade username
  variant?: 'compact' | 'detailed' | 'minimal';
  dark?: boolean;             // Enable dark theme
  roundness?: 'sm' | 'md' | 'lg' | 'xl';
  loading?: boolean;          // Set loading state
  error?: string | null;      // Set error state dynamically while fetching
  data?: {                    // Optional: provide custom data
    codeQuality: number;
    dominantLanguage: string;
    githubProfile: string;
    grade: 'S' | 'A' | 'B' | 'C' | 'D';
    hireability: number;
    intelligence: number;
  };
}

Fetching Data Programmatically

Use the DevGrade API directly to fetch developer metrics and build custom components:

Fetch DevGrade Data

Retrieve developer metrics using the DevGrade API endpoint:

"use client";
import { useState, useEffect } from 'react';

// Custom hook to fetch DevGrade data
function useDevGradeData(username) {
  const [data, setData] = useState(null);
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState(null);

  useEffect(() => {
    const LOCAL_STORAGE_KEY = 'x_devgrade_result_';
    async function fetchData() {
      try {
        const storageKey = '${LOCAL_STORAGE_KEY}${username}';
        const storedData = localStorage.getItem(storageKey);

        if (storedData) {
          setData(JSON.parse(storedData));
          setLoading(false);
          return;
        }

        const res = await fetch(`https://devgrade.vercel.app/api/dev-grade/${username}`);
        const result = await res.json();
        
        if (result.success) {
          setData(result.devGrade);
          localStorage.setItem(storageKey, JSON.stringify(result.devGrade));
        }

        if (result.error) {
          setError(result.error);
        }
        
        } catch (err) {
        if (err instanceof Error) {
          setError(err.message);
        } else {
          setError('An unknown error occurred');
        }
      } finally {
        setLoading(false);
      }
    }

    fetchData();
  }, [username]);

  return { data, loading, error };
}

// Example usage in component
function CustomBadge({ username }) {
  const { data, loading, error } = useDevGradeData(username);

  return (
      <DevGradeBadge
        loading={loading}
        roundness="sm"
        data={data}
        error={error}
        dark={true}
        variant="detailed"
      />
  );
}

Framework Integration

Example showing how to integrate the badge in a Next.js application:

Next.js Integration

Example integration in a Next.js portfolio page:

'use client';
import { DevGradeBadge } from 'devgrade-badge';
import { useDevGradeData } from '@hooks/useDevGradeDataHook';

export default function AboutPage() {
const { data, loading, error } = useDevGradeData(username);

  return (
    <section className="py-16">
      <div className="container mx-auto">
        <h1>About Me</h1>
        <p>I'm a full-stack developer...</p>
        
      <DevGradeBadge
        loading={loading}
        roundness="sm"
        data={data}
        error={error}
        dark={true}
        variant="detailed"
      />   

      </div>
    </section>
  );
}

Integration Tips

🎨 Styling

The badge uses Tailwind CSS classes and respects your site's dark mode settings automatically.

📱 Responsive

All variants are fully responsive and work great on mobile devices.

🔗 Interactive

Badges include clickable GitHub profile links and hover effects for better user engagement.

♿ Accessible

Built with semantic HTML and ARIA labels for screen reader compatibility.