next-best-practices
oleh sanity-io
Praktik terbaik Next.js - konvensi file, batasan RSC, pola data, API asinkron, metadata, penanganan kesalahan, penangan rute, optimasi gambar/font,…
npx skills add https://github.com/sanity-io/next-sanity --skill next-best-practicesNext.js Best Practices
Apply these rules when writing or reviewing Next.js code.
File Conventions
See file-conventions.md for:
- Project structure and special files
- Route segments (dynamic, catch-all, groups)
- Parallel and intercepting routes
- Middleware rename in v16 (middleware → proxy)
RSC Boundaries
Detect invalid React Server Component patterns.
See rsc-boundaries.md for:
- Async client component detection (invalid)
- Non-serializable props detection
- Server Action exceptions
Async Patterns
Next.js 15+ async API changes.
See async-patterns.md for:
- Async
paramsandsearchParams - Async
cookies()andheaders() - Migration codemod
Runtime Selection
See runtime-selection.md for:
- Default to Node.js runtime
- When Edge runtime is appropriate
Directives
See directives.md for:
'use client','use server'(React)'use cache'(Next.js)
Functions
See functions.md for:
- Navigation hooks:
useRouter,usePathname,useSearchParams,useParams - Server functions:
cookies,headers,draftMode,after - Generate functions:
generateStaticParams,generateMetadata
Error Handling
See error-handling.md for:
error.tsx,global-error.tsx,not-found.tsxredirect,permanentRedirect,notFoundforbidden,unauthorized(auth errors)unstable_rethrowfor catch blocks
Data Patterns
See data-patterns.md for:
- Server Components vs Server Actions vs Route Handlers
- Avoiding data waterfalls (
Promise.all, Suspense, preload) - Client component data fetching
Route Handlers
See route-handlers.md for:
route.tsbasics- GET handler conflicts with
page.tsx - Environment behavior (no React DOM)
- When to use vs Server Actions
Metadata & OG Images
See metadata.md for:
- Static and dynamic metadata
generateMetadatafunction- OG image generation with
next/og - File-based metadata conventions
Image Optimization
See image.md for:
- Always use
next/imageover<img> - Remote images configuration
- Responsive
sizesattribute - Blur placeholders
- Priority loading for LCP
Font Optimization
See font.md for:
next/fontsetup- Google Fonts, local fonts
- Tailwind CSS integration
- Preloading subsets
Bundling
See bundling.md for:
- Server-incompatible packages
- CSS imports (not link tags)
- Polyfills (already included)
- ESM/CommonJS issues
- Bundle analysis
Scripts
See scripts.md for:
next/scriptvs native script tags- Inline scripts need
id - Loading strategies
- Google Analytics with
@next/third-parties
Hydration Errors
See hydration-error.md for:
- Common causes (browser APIs, dates, invalid HTML)
- Debugging with error overlay
- Fixes for each cause
Suspense Boundaries
See suspense-boundaries.md for:
- CSR bailout with
useSearchParamsandusePathname - Which hooks require Suspense boundaries
Parallel & Intercepting Routes
See parallel-routes.md for:
- Modal patterns with
@slotand(.)interceptors default.tsxfor fallbacks- Closing modals correctly with
router.back()
Self-Hosting
See self-hosting.md for:
output: 'standalone'for Docker- Cache handlers for multi-instance ISR
- What works vs needs extra setup
Debug Tricks
See debug-tricks.md for:
- MCP endpoint for AI-assisted debugging
- Rebuild specific routes with
--debug-build-paths
Lebih banyak skill dari sanity-io
sanity-migration
sanity-io
Merencanakan, mengimplementasikan, dan meninjau migrasi dari CMS lain serta sistem konten ke Sanity. Gunakan saat melakukan migrasi atau replatforming ke Sanity dari AEM, Adobe Experience Manager, Contentful, Strapi, Webflow, WordPress, Payload, Drupal, file Markdown/MDX/frontmatter, ekspor WXR/XML, API CMS, dump database, HTML statis, atau saat merancang alur kerja ekstraksi, transformasi, konversi Portable Text, migrasi aset, pengalihan, validasi, dan cutover.
officialdevelopmentdatabase
create-agent-with-sanity-context
sanity-io
Bangun agen AI dengan akses terstruktur ke konten Sanity melalui Agent Context. Gunakan saat menyiapkan chatbot bertenaga Sanity, menghubungkan asisten AI ke Sanity…
official
dial-your-context
sanity-io
Sesi interaktif untuk membuat konten kolom Instruksi bagi Sanity Agent Context MCP. Gunakan skill ini setiap kali pengguna menyebutkan penyesuaian konteks agen, meningkatkan…
official
optimize-agent-prompt
sanity-io
Sesuaikan agen Konteks Agen Sanity Anda melalui percakapan terpandu. Mengubah data eksplorasi menjadi instruksi siap produksi dan menyusun prompt sistem…
official
shape-your-agent
sanity-io
Sesi interaktif untuk menyusun prompt sistem bagi agen AI yang didukung oleh Sanity Agent Context MCP. Gunakan keterampilan ini ketika pengguna ingin mendefinisikan kepribadian agen,…
official
content-experimentation-best-practices
sanity-io
Panduan terstruktur untuk merancang, menjalankan, dan menganalisis eksperimen konten guna meningkatkan konversi dan keterlibatan. Mencakup kerangka hipotesis, pemilihan metrik, perhitungan ukuran sampel, dan pengujian signifikansi statistik dalam eksperimen A/B dan multivariat. Menyertakan sumber daya terperinci tentang nilai-p, interval kepercayaan, analisis kekuatan, dan metode Bayesian untuk menafsirkan hasil. Menyediakan pola integrasi CMS untuk mengelola varian di tingkat bidang dan menghubungkan eksternal...
official
content-modeling-best-practices
sanity-io
Panduan pemodelan konten terstruktur untuk desain skema, penggunaan ulang, dan pengiriman multi-saluran. Mencakup prinsip inti: memperlakukan konten sebagai data, bukan halaman, mempertahankan sumber kebenaran tunggal, mendesain untuk saluran masa depan, dan mengoptimalkan alur kerja editor. Termasuk kerangka keputusan untuk referensi versus objek tersemat, pemisahan perhatian, dan pola penggunaan ulang konten. Memberikan panduan taksonomi dan klasifikasi untuk pendekatan datar, hierarkis, dan faset. Berlaku untuk...
official
portable-text-conversion
sanity-io
Konversi konten HTML dan Markdown menjadi blok Portable Text untuk Sanity. Gunakan saat memigrasi konten dari CMS lama, mengimpor HTML atau Markdown ke Sanity,…
official