aiskillstore/marketplace/frontend-component

Claude Code and agent skill by aiskillstore/marketplace

Trust tier 3
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Tainted

Author "aiskillstore" has blocked skill(s)

Next.js 16+ uses App Router with Server Components by default. Client Components are only used when interactivity is needed (hooks, event handlers, browser APIs).

Install

npx vskill@latest install aiskillstore/marketplace/frontend-component

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as aiskillstore/marketplace/frontend-component.

Frontend Component Skill

Purpose: Guidance for creating Next.js components following server/client patterns and existing component structures.

Overview

Next.js 16+ uses App Router with Server Components by default. Client Components are only used when interactivity is needed (hooks, event handlers, browser APIs).

Server vs Client Components

Server Components (Default)

When to Use:

  • Pages and layouts
  • Static content
  • Data fetching from API (when possible)
  • SEO-optimized content

Pattern:

typescript
// No "use client" directive
import { Metadata } from "next";
export const metadata: Metadata = {
title: "Page Title",
};
export default function PageComponent() {
return <div>Static content</div>;
}

Example: frontend/app/layout.tsx, frontend/app/page.tsx

Client Components (When Needed)

When to Use:

  • Interactive elements (buttons, forms, inputs)
  • Event handlers (onClick, onChange, etc.)
  • React hooks (useState, useEffect, useRouter, etc.)
  • Browser APIs (localStorage, window, document, etc.)
  • Real-time updates
  • Drag and drop functionality

Pattern:

typescript
"use client"; // MUST be first line
import { useState, useEffect } from "react";
import { useRouter } from "next/navigation";
interface ComponentProps {
prop1: string;
prop2?: number;
}
export default function ComponentName({ prop1, prop2 }: ComponentProps) {
const router = useRouter();
const [state, setState] = useState("");
useEffect(() => {
// Side effects
}, []);
return <div>{/* Component JSX */}</div>;
}

Example: frontend/components/ProtectedRoute.tsx, frontend/app/signup/page.tsx

Component Structure Template

typescript
"use client"; // Only if client component
/**
* Component Name
*
* Brief description of what this component does
*/
import { useState, useEffect } from "react";
import { ComponentType } from "@/types";
import { cn } from "@/lib/utils";
interface ComponentProps {
prop1: string;
prop2?: number;
className?: string;
}
export default function ComponentName({ prop1, prop2, className }: ComponentProps) {
// State
const [state, setState] = useState("");
// Effects
useEffect(() => {
// Side effects
}, []);
// Handlers
const handleClick = () => {
// Handler logic
};
// Render
return (
<div className={cn("base-classes", className)}>
{/* Component content */}
</div>
);
}

Specific Component Patterns

1. ProtectedRoute Pattern

From: frontend/components/ProtectedRoute.tsx

typescript
"use client";
import { useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import { isAuthenticated } from "@/lib/auth";
import LoadingSpinner from "./LoadingSpinner";
interface ProtectedRouteProps {
children: React.ReactNode;
}
export default function ProtectedRoute({ children }: ProtectedRouteProps) {
const router = useRouter();
const [isAuthorized, setIsAuthorized] = useState(false);
const [isChecking, setIsChecking] = useState(true);
useEffect(() => {
async function checkAuth() {
try {
const authenticated = await isAuthenticated();
if (!authenticated) {
const currentPath = window.location.pathname;
if (currentPath !== "/signin") {
sessionStorage.setItem("redirectAfterLogin", currentPath);
}
router.push("/signin");
} else {
setIsAuthorized(true);
}
} catch (error) {
console.error("Auth check failed:", error);
router.push("/signin");
} finally {
setIsChecking(false);
}
}
checkAuth();
}, [router]);
if (isChecking) {
return (
<div className="min-h-screen flex items-center justify-center">
<LoadingSpinner size="large" />
</div>
);
}
if (!isAuthorized) {
return null;
}
return <>{children}</>;
}

Pattern:

  • Check authentication on mount
  • Show loading spinner during check
  • Store intended destination in sessionStorage
  • Redirect to /signin if not authenticated
  • Only render children if authorized
2. LoadingSpinner Pattern

From: frontend/components/LoadingSpinner.tsx

typescript
interface LoadingSpinnerProps {
size?: "small" | "medium" | "large";
color?: string;
label?: string;
}
export default function LoadingSpinner({
size = "medium",
color = "blue",
label = "Loading...",
}: LoadingSpinnerProps) {
const sizeClasses = {
small: "w-4 h-4 border-2",
medium: "w-8 h-8 border-3",
large: "w-12 h-12 border-4",
};
const colorClasses = {
blue: "border-blue-600 border-t-transparent",
gray: "border-gray-600 border-t-transparent",
white: "border-white border-t-transparent",
};
const spinnerClass = `${sizeClasses[size]} ${
colorClasses[color as keyof typeof colorClasses] || colorClasses.blue
} rounded-full animate-spin`;
return (
<div
className="flex items-center justify-center"
role="status"
aria-label={label}
aria-live="polite"
>
<div className={spinnerClass}></div>
<span className="sr-only">{label}</span>
</div>
);
}

Pattern:

  • Multiple sizes (small, medium, large)
  • Multiple colors (blue, gray, white)
  • Accessibility labels (role="status", aria-label, aria-live)
  • Screen reader text with sr-only class
3. Form Handling Pattern

From: frontend/app/signup/page.tsx

typescript
"use client";
import { useState } from "react";
import { useRouter } from "next/navigation";
import { api } from "@/lib/api";
import { isValidEmail, getPasswordStrength } from "@/lib/utils";
export default function SignupPage() {
const router = useRouter();
const [formData, setFormData] = useState({
name: "",
email: "",
password: "",
});
const [errors, setErrors] = useState<Record<string, string>>({});
const [isLoading, setIsLoading] = useState(false);
const [apiError, setApiError] = useState("");
const validateForm = (): boolean => {
const newErrors: Record<string, string> = {};
if (!formData.name.trim()) {
newErrors.name = "Name is required";
}
if (!formData.email.trim()) {
newErrors.email = "Email is required";
} else if (!isValidEmail(formData.email)) {
newErrors.email = "Please enter a valid email address";
}
// More validation...
setErrors(newErrors);
return Object.keys(newErrors).length === 0;
};
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setApiError("");
if (!validateForm()) {
return;
}
setIsLoading(true);
try {
const response = await api.signup(formData);
if (response.success) {
router.push("/dashboard");
} else {
setApiError(response.message || "Signup failed");
}
} catch (error: any) {
setApiError(error.message || "An error occurred");
} finally {
setIsLoading(false);
}
};
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = e.target;
setFormData((prev) => ({ ...prev, [name]: value }));
// Clear error for this field when user starts typing
if (errors[name]) {
setErrors((prev) => ({ ...prev, [name]: "" }));
}
};
return (
<form onSubmit={handleSubmit}>
{/* Form fields */}
</form>
);
}

Pattern:

  • Separate state for form data, errors, loading, API errors
  • Validation function that returns boolean
  • Clear errors on input change
  • Loading state during submission
  • Try-catch for error handling
  • Redirect on success
4. ToastNotification Pattern

From: frontend/components/ToastNotification.tsx

typescript
"use client";
import { useEffect, useState } from "react";
import { ToastMessage, ToastType } from "@/types";
export function useToast() {
const [toasts, setToasts] = useState<ToastMessage[]>([]);
const showToast = (type: ToastType, message: string, duration?: number) => {
const id = `toast-${Date.now()}-${Math.random()}`;
const newToast: ToastMessage = {
id,
type,
message,
duration,
};
setToasts((prev) => [...prev, newToast]);
};
const dismissToast = (id: string) => {
setToasts((prev) => prev.filter((toast) => toast.id !== id));
};
return {
toasts,
showToast,
dismissToast,
success: (message: string, duration?: number) => showToast("success", message, duration),
error: (message: string, duration?: number) => showToast("error", message, duration),
// ...
};
}

Pattern:

  • Custom hook for toast management
  • Auto-dismiss with duration
  • Stack multiple toasts
  • Helper methods (success, error, warning, info)

Tailwind CSS Patterns

1. Utility Classes Only
typescript
<div className="flex items-center justify-center gap-4 p-6 bg-white rounded-lg shadow-md">

Pattern: Use Tailwind utility classes, no inline styles

2. Conditional Classes with cn() Utility
typescript
import { cn } from "@/lib/utils";
<div className={cn(
"base-classes",
condition && "conditional-classes",
className // Allow prop override
)}>

Pattern: Use cn() from @/lib/utils for conditional classes

3. Dark Mode Support
typescript
<div className="bg-white dark:bg-gray-800 text-gray-900 dark:text-white">

Pattern: Use dark: prefix for dark mode styles

4. Responsive Design
typescript
<div className="w-full sm:w-1/2 md:w-1/3 lg:w-1/4">

Pattern: Use breakpoint prefixes (sm:, md:, lg:, xl:)

Accessibility Patterns (WCAG 2.1 AA)

1. ARIA Labels
typescript
<button aria-label="Close dialog">×</button>
<div role="status" aria-live="polite" aria-label="Loading...">

Pattern: Always provide aria-label for icon-only buttons

2. Semantic HTML
typescript
<nav>
<ul>
<li><a href="/">Home</a></li>
</ul>
</nav>

Pattern: Use semantic HTML elements (nav, main, section, article, etc.)

3. Keyboard Navigation
typescript
<button
onClick={handleClick}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
handleClick();
}
}}
>

Pattern: Ensure keyboard accessibility for all interactive elements

4. Screen Reader Text
typescript
<span className="sr-only">Loading content</span>

Pattern: Use sr-only class for screen reader-only text

5. Focus Management
typescript
<input
autoFocus
className="focus:outline-none focus:ring-2 focus:ring-blue-500"
/>

Pattern: Always provide visible focus indicators

File Naming Conventions

  • Pages: kebab-case (e.g., signup.tsx, signin.tsx)
  • Components: PascalCase (e.g., TaskList.tsx, TaskItem.tsx)
  • Layouts: layout.tsx
  • Error Pages: error.tsx, not-found.tsx

Constitution Requirements

  • FR-033: Next.js 16+ App Router structure ✅
  • FR-034: Server components default, client when needed ✅
  • FR-035: Error boundaries ✅
  • FR-036: WCAG 2.1 AA compliance ✅
  • FR-037: TypeScript strict mode ✅
  • FR-038: Prettier formatting ✅
  • FR-039: ESLint rules ✅

References

  • Specification: specs/002-frontend-todo-app/spec.md - Component specifications
  • Existing Components: frontend/components/*.tsx - Component examples
  • Existing Pages: frontend/app/*.tsx - Page examples

Advanced Component Patterns

1. Drag and Drop Pattern (Phase 7 - T065)

Library: @dnd-kit/core

typescript
"use client";
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors } from "@dnd-kit/core";
import { SortableContext, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
429
Repository forks
45
7-day trend score
30

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/aiskillstore/marketplace/frontend-component/badge)](https://verified-skill.com/skills/aiskillstore/marketplace/frontend-component)

Something wrong with this skill or its page? Tell us.