Receber por email
← Voltar para o catálogo

frontend-dev-guidelines

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

367estrelas
Atualizado há 4 meses

Ver no GitHub ↗

Como adicionar

/plugin marketplace add aiskillstore/marketplace

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Para o autor da skill

Cole no README do seu repo

Mostra que sua skill está catalogada na Skillteca, gera backlink e tráfego rastreável.

[![Skillteca](https://www.skillteca.com.br/api/badge/frontend-dev-guidelines-aiskillstore/svg)](https://www.skillteca.com.br/skills/frontend-dev-guidelines-aiskillstore)

Alerta por categoria

Receba novas skills de Design e Frontend toda segunda

1 email curto, só com as skills novas de Design e Frontend. 4 minutos de leitura, sem spam, cancela com 1 clique.

Você confirma o email no primeiro envio. Sem spam. Cancela com 1 clique.

Ler descrição completa

Frontend Development Guidelines

Purpose

Comprehensive guide for modern Next.js 15 development with React 19, emphasizing Server Components, Client Components, App Router patterns, Shadcn/ui components, proper file organization, and performance optimization.

When to Use This Skill

  • Creating new components or pages
  • Building new features
  • Fetching data (Server Components, Server Actions)
  • Setting up routing with Next.js App Router
  • Styling components with Tailwind CSS and Shadcn/ui
  • Performance optimization
  • Organizing frontend code
  • TypeScript best practices

Quick Start

New Component Checklist

Creating a component? Follow this checklist:

  • [ ] Determine Server vs Client Component (default: Server Component)
  • [ ] Add "use client" directive only if needed (interactivity, hooks, browser APIs)
  • [ ] Use TypeScript with explicit prop types
  • [ ] Import Shadcn/ui components from @/components/ui
  • [ ] Use Tailwind CSS classes for styling
  • [ ] Import aliases: @/components, @/lib, @/hooks
  • [ ] Use cn() utility for conditional classes
  • [ ] Default export at bottom
  • [ ] Use Server Components for data fetching when possible

New Page Checklist

Creating a page? Set up this structure:

  • [ ] Create app/{route-name}/page.tsx for route
  • [ ] Use Server Component by default
  • [ ] Fetch data directly in Server Component
  • [ ] Create components/ directory for page-specific components
  • [ ] Use loading.tsx for loading states
  • [ ] Use error.tsx for error boundaries
  • [ ] Export metadata for SEO

Import Aliases Quick Reference

| Alias | Resolves To | Example | | -------------- | ------------- | ------------------------------------------------- | | @/ | Project root | import { cn } from '@/lib/utils' | | @/components | components/ | import { Button } from '@/components/ui/button' | | @/lib | lib/ | import { cn } from '@/lib/utils' | | @/hooks | hooks/ | import { useMobile } from '@/hooks/use-mobile' | | @/app | app/ | import { Metadata } from 'next' |

Defined in: tsconfig.json paths configuration

Common Imports Cheatsheet

// Next.js
import { Metadata } from 'next'
import { Suspense } from 'react'
import { notFound, redirect } from 'next/navigation'

// React (Client Components only)
;('use client')
import { useState, useCallback, useMemo } from 'react'

// Shadcn/ui Components
import { Button } from '@/components/ui/button'
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card'
import { Input } from '@/components/ui/input'

// Utilities
import { cn } from '@/lib/utils'

// Hooks (Client Components only)
import { useMobile } from '@/hooks/use-mobile'

// Types
import type { ComponentProps } from 'react'

Topic Guides

🎨 Component Patterns

Server Components vs Client Components:

  • Server Components (default): No "use client", can fetch data directly, smaller bundle
  • Client Components: Add "use client" for interactivity, hooks, browser APIs

Key Concepts:

  • Default to Server Components
  • Only use Client Components when necessary
  • Use Shadcn/ui components (already Client Components)
  • Component structure: Props → Data Fetching → Render → Export

Example Server Component:

// app/features/posts/components/PostList.tsx
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card'

interface PostListProps {
  posts: Post[]
}

export function PostList({ posts }: PostListProps) {
  return (
    <div className='grid gap-4'>
      {posts.map((post) => (
        <Card key={post.id}>
          <CardHeader>
            <CardTitle>{post.title}</CardTitle>
          </CardHeader>
          <CardContent>{post.content}</CardContent>
        </Card>
      ))}
    </div>
  )
}

Example Client Component:

// app/features/posts/components/PostForm.tsx
'use client'

import { useState } from 'react'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'

export function PostForm() {
  const [title, setTitle] = useState('')

  return (
    <form>
      <Input value={title} onChange={(e) => setTitle(e.target.value)} />
      <Button type='submit'>Submit</Button>
    </form>
  )
}

📊 Data Fetching

PRIMARY PATTERN: Server Components

  • Fetch data directly in Server Components
  • Use async/await in Server Components
  • No need for useEffect or data fetching libraries
  • Automatic request deduplication

Server Actions:

  • Use for mutations (forms, updates)
  • Create app/actions/ directory
  • Mark with "use server" directive

Example Server Component with Data Fetching:

// app/posts/page.tsx
import { PostList } from '@/components/PostList'

async function getPosts() {
  const res = await fetch('https://api.example.com/posts', {
    cache: 'no-store', // or 'force-cache', 'revalidate'
  })
  return res.json()
}

export default async function PostsPage() {
  const posts = await getPosts()

  return <PostList posts={posts} />
}

Example Server Action:

// app/actions/posts.ts
'use server'

export async function createPost(formData: FormData) {
  const title = formData.get('title')
  // ... validation and creation logic
  redirect('/posts')
}

📁 File Organization

App Router Structure:

app/
  (routes)/
    page.tsx          # Route page
    layout.tsx        # Route layout
    loading.tsx       # Loading UI
    error.tsx         # Error UI
  components/         # Shared components
    ui/               # Shadcn/ui components
  features/           # Feature-specific code
    posts/
      components/     # Feature components
      actions/        # Server Actions
      types/          # TypeScript types
lib/
  utils.ts            # Utilities (cn, etc.)
hooks/
  use-mobile.ts       # Custom hooks (Client only)

Feature Organization:

  • app/features/{feature}/: Feature-specific pages/routes
  • components/: Truly reusable components
  • components/ui/: Shadcn/ui components (don't modify directly)

🎨 Styling

Tailwind CSS + Shadcn/ui:

  • Use Tailwind utility classes
  • Use cn() utility for conditional classes
  • Shadcn/ui components use CSS variables for theming
  • Customize theme in app/globals.css

Styling Patterns:

import { cn } from '@/lib/utils'

interface ButtonProps {
  variant?: 'primary' | 'secondary'
  className?: string
}

export function Button({ variant = 'primary', className }: ButtonProps) {
  return (
    <button
      className={cn(
        'rounded-md px-4 py-2',
        variant === 'primary' && 'bg-primary text-primary-foreground',
        variant === 'secondary' && 'bg-secondary text-secondary-foreground',
        className,
      )}
    >
      Click me
    </button>
  )
}

Shadcn/ui Components:

  • Import from @/components/ui/{component-name}
  • Components are already styled and accessible
  • Customize via className prop or CSS variables

🛣️ Routing

Next.js App Router - File-Based:

  • Directory: app/{route-name}/page.tsx
  • Nested routes: app/{parent}/{child}/page.tsx
  • Dynamic routes: app/posts/[id]/page.tsx
  • Route groups: app/(marketing)/about/page.tsx

Example Route:

// app/posts/page.tsx
import { Metadata } from 'next'
import { PostList } from '@/components/PostList'

export const metadata: Metadata = {
  title: 'Posts',
  description: 'List of all posts',
}

export default async function PostsPage() {
  const posts = await getPosts()

  return (
    <div className='container mx-auto py-8'>
      <h1 className='text-3xl font-bold mb-6'>Posts</h1>
      <PostList posts={posts} />
    </div>
  )
}

Dynamic Route:

// app/posts/[id]/page.tsx
interfac
Compartilhar X LinkedIn