Communitygithub.com

ASoudy/AGS

Prinzipien des Next.js App Router. Server-Komponenten, Datenabruf, Routing-Muster.

Was ist AGS?

Diese Skill-Datei definiert Best Practices für die Entwicklung mit Next.js App Router. Sie bietet eine klare Entscheidungsmatrix für die Wahl zwischen Server- und Client-Komponenten, Richtlinien für Datenabrufstrategien (statisch, ISR, dynamisch) sowie fundamentale Routing-Prinzipien mit Dateikonventionen (page.tsx, layout.tsx, loading.tsx etc.). Darüber hinaus werden API-Routen-Handler, Performance-Optimierung (next/image, dynamische Imports), Caching-Strategien, Server Actions und häufige Anti-Patterns behandelt. Die Skill ist auf Entwicklerplattformen wie Claude Code, Cursor oder Codex anwendbar, die Kontext aus Markdown-Dateien verstehen, und hilft dabei, konsistente, performante und wartbare Next.js-Anwendungen zu erstellen. Sie sollte immer dann verwendet werden, wenn der aktuelle Task die Entwicklung oder Analyse einer Next.js-App betrifft – andernfalls ist sie nicht anzuwenden.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ASoudy/AGS/tree/HEAD/AGAS/plugins/antigravity-awesome-skills-claude/skills/nextjs-best-practices

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Next.js Best Practices

Prinzipien für die Entwicklung mit Next.js App Router.


1. Server- vs. Client-Komponenten

Entscheidungsbaum

Braucht es...?
│
├── useState, useEffect, Event-Handler
│   └── Client-Komponente ('use client')
│
├── Direkter Datenabruf, keine Interaktivität
│   └── Server-Komponente (Standard)
│
└── Beides?
    └── Aufteilen: Server-Eltern + Client-Kind

Standardmäßig

TypVerwendung
ServerDatenabruf, Layout, statische Inhalte
ClientFormulare, Schaltflächen, interaktive UI

2. Datenabrufmuster

Abrufstrategie

MusterVerwendung
StandardStatisch (beim Build gecached)
RevalidateISR (zeitbasierte Aktualisierung)
No-storeDynamisch (bei jeder Anfrage)

Datenfluss

QuelleMuster
DatenbankServer-Komponenten-Abruf
APIfetch mit Caching
BenutzereingabeClient-Status + Server-Aktion

3. Routing-Prinzipien

Dateikonventionen

DateiZweck
page.tsxRouten-UI
layout.tsxGemeinsames Layout
loading.tsxLadezustand
error.tsxFehlerbegrenzung
not-found.tsx404-Seite

Routenorganisation

MusterVerwendung
Routengruppen (name)Organisieren ohne URL-Änderung
Parallele Routen @slotMehrere gleichzeitige Seiten
Abfangen (.)Modale Overlays

4. API-Routen

Routen-Handler

MethodeVerwendung
GETDaten lesen
POSTDaten erstellen
PUT/PATCHDaten aktualisieren
DELETEDaten löschen

Best Practices

  • Eingaben mit Zod validieren
  • Korrekte Statuscodes zurückgeben
  • Fehler ordentlich behandeln
  • Nach Möglichkeit Edge Runtime verwenden

5. Leistungsprinzipien

Bildoptimierung

  • next/image-Komponente verwenden
  • Priorität für oberhalb der Falz setzen
  • Blur-Placeholder bereitstellen
  • Responsive Größen verwenden

Bundle-Optimierung

  • Dynamische Importe für schwere Komponenten
  • Routenbasiertes Code-Splitting (automatisch)
  • Mit Bundle-Analyzer analysieren

6. Metadaten

Statisch vs. Dynamisch

TypVerwendung
Statischer ExportFeste Metadaten
generateMetadataDynamisch pro Route

Wesentliche Tags

  • title (50–60 Zeichen)
  • description (150–160 Zeichen)
  • Open-Graph-Bilder
  • Kanonische URL

7. Caching-Strategie

Cache-Ebenen

EbeneSteuerung
Anfragefetch-Optionen
Datenrevalidate/tags
Ganze RouteRoutenkonfiguration

Aktualisierung (Revalidation)

MethodeVerwendung
Zeitbasiertrevalidate: 60
On-DemandrevalidatePath/Tag
Kein Cacheno-store

8. Server-Aktionen

Anwendungsfälle

  • Formularübermittlungen
  • Datenänderungen
  • Aktualisierungsauslöser

Best Practices

  • Mit 'use server' markieren
  • Alle Eingaben validieren
  • Typisierte Antworten zurückgeben
  • Fehler behandeln

9. Anti-Patterns

❌ Nicht tun✅ Stattdessen
'use client' überallServer als Standard
Daten in Client-Komponenten abrufenDaten im Server abrufen
Ladezustände überspringenloading.tsx verwenden
Fehlergrenzen ignorierenerror.tsx verwenden
Große Client-BundlesDynamische Importe

10. Projektstruktur

app/
├── (marketing)/     # Routengruppe
│   └── page.tsx
├── (dashboard)/
│   ├── layout.tsx   # Dashboard-Layout
│   └── page.tsx
├── api/
│   └── [resource]/
│       └── route.ts
└── components/
    └── ui/

Denk dran: Server-Komponenten sind aus gutem Grund der Standard. Starte dort und füge Client nur hinzu, wenn nötig.

Wann verwenden

Diese Skill ist anwendbar, um den im Überblick beschriebenen Workflow oder die Aktionen auszuführen.

Einschränkungen

  • Verwende diese Skill nur, wenn die Aufgabe klar mit dem oben beschriebenen Umfang übereinstimmt.
  • Behandle die Ausgabe nicht als Ersatz für umgebungsspezifische Validierung, Tests oder Expertenprüfung.
  • Halte inne und frage nach, wenn erforderliche Eingaben, Berechtigungen, Sicherheitsgrenzen oder Erfolgskriterien fehlen.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ASoudy/AGS

Advanced JavaScript animation library skill for creating complex, high-performance web animations.

ASoudy/AGS

Astropy is the core Python package for astronomy, providing essential functionality for astronomical research and data analysis.

ASoudy/AGS

Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support.

ASoudy/AGS

One sentence - what this skill does and when to invoke it

ASoudy/AGS

Audit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects. Use when animations stutter, transitions jank, or reviewing CSS/JS animation performance.

ASoudy/AGS

Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.

ASoudy/AGS

Pull a YouTube video transcript into a queryable markdown vault with yt-dlp subtitle discovery, VTT cleanup, metadata frontmatter, and capture-seed stubs.

ASoudy/AGS

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities.

ASoudy/AGS

Generates high-converting Next.js/React landing pages with Tailwind CSS. Uses PAS, AIDA, and BAB frameworks for optimized copy/components (Heroes, Features, Pricing). Focuses on Core Web Vitals/SEO.

ASoudy/AGS

AI-powered animation tool for creating motion in logos, UI, icons, and social media assets.

ASoudy/AGS

CRITICAL: Use for Makepad animation system. Triggers on: makepad animation, makepad animator, makepad hover, makepad state, makepad transition, "from: { all: Forward", makepad pressed, makepad 动画, makepad 状态, makepad 过渡, makepad 悬停效果

ASoudy/AGS

Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

ASoudy/AGS

Expert integration of Supabase Auth with Next.js App Router

ASoudy/AGS

React and Next.js 14+ application development with App Router, Server Components, TypeScript, Tailwind CSS, and modern frontend patterns.

ASoudy/AGS

Best practices for Remotion - Video creation in React

ASoudy/AGS

Generate walkthrough videos from Stitch projects using Remotion with smooth transitions, zooming, and text overlays

ASoudy/AGS

Seek and analyze video content using Memories.ai Large Visual Memory Model for persistent video intelligence

ASoudy/AGS

Writes complete, structured landing pages optimized for SEO ranking, AEO citation, and visitor conversion. Activate when the user wants to write or generate a landing page for a product, service, or offer.

ASoudy/AGS

Three.js animation - keyframe animation, skeletal animation, morph targets, animation mixing. Use when animating objects, playing GLTF animations, creating procedural motion, or blending animations.

ASoudy/AGS

Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

Verwandte Skills