[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EV3JSZ9KMJFYJEHY211B2Y":3,"skill-same:01M7EV3JSZ9KMJFYJEHY211B2Y":45},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7EV3JSZ9KMJFYJEHY211B2Y","ams-nextjs-patterns",null,"TanNhatCMS\u002Fjarvis","TanNhatCMS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F113796420?v=4","01M753MV17KG5CD3152G3WQEQY","KietNT","01M7EKEDYVYQ6PWVJJMZ911VMX",0,"MIT","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fams-nextjs-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: nextjs-patterns\ndescription: Build with Next.js App Router: routing, server\u002Fclient components, data fetching, caching, metadata, and deployment. Use when developing Next.js applications.\ncategory: web-development\n---\n\n# Next.js Patterns\n\nA practical guide to Next.js (App Router): the file-system router, Server vs Client Components, data fetching and caching, metadata\u002FSEO, and production deployment patterns.\n\n## Overview\n\nNext.js App Router splits your app into **Server Components** (default: render on the server, zero client JS, direct backend access) and **Client Components** (`'use client'`: interactivity, hooks, browser APIs). The key skill is knowing which to use where: push data fetching and rendering to the server, keep client components small and leaf-ward. Everything else — caching, streaming, metadata — follows from that split.\n\n## When to use\n\n- Full-stack React apps: marketing sites, dashboards, SaaS.\n- SSR\u002FSSG\u002FISR rendering strategies per route.\n- API routes (Route Handlers) colocated with the frontend.\n- Migrating Pages Router → App Router.\n- Optimizing Next.js bundle size and caching behavior.\n\n## Core concepts\n\n- **App Router files.** `app\u002Fpage.tsx` (route UI), `layout.tsx` (shared shell), `loading.tsx` (Suspense fallback), `error.tsx` (error boundary), `not-found.tsx`, `route.ts` (API endpoint), `page.tsx` dynamic via `[slug]`.\n- **Server Components (default).** Async components that fetch directly: `const data = await db.query(...)` in the component. No `useState`\u002F`useEffect`\u002Fbrowser APIs. Ship zero JS for their subtree.\n- **Client Components.** `'use client'` at the top — needed for interactivity. Keep them small; pass server-fetched data as props rather than re-fetching client-side.\n- **Data fetching.** `fetch` in Server Components is cached by default; `cache: 'no-store'` for dynamic, `next: { revalidate: 60 }` for ISR. `generateStaticParams` for static dynamic routes.\n- **Streaming.** `loading.tsx` + `\u003CSuspense>` stream parts of the page as they resolve — fast TTFB with slow data. Wrap slow components, not whole pages.\n- **Server Actions.** `'use server'` functions called from client components — mutations without an API layer. Validate inputs (Zod), check auth, revalidate with `revalidatePath`.\n- **Metadata.** `export const metadata = {...}` \u002F `generateMetadata()` per route — title, description, Open Graph. The SEO story.\n- **Caching layers.** Request memoization → Data Cache → Full Route Cache → Router Cache. Know which layer you're invalidating (`revalidatePath` vs `revalidateTag`).\n\n## Practical workflow\n\n**1. Route structure.**\n```\napp\u002F\n  layout.tsx            # \u003Chtml>, fonts, providers\n  page.tsx              # \u002F\n  blog\u002F[slug]\u002Fpage.tsx  # \u002Fblog\u002F:slug\n  blog\u002F[slug]\u002Floading.tsx\n  dashboard\u002Flayout.tsx  # nested layout\n  api\u002Fwebhooks\u002Froute.ts # API endpoint\n```\n\n**2. Server-first data.**\n```tsx\n\u002F\u002F app\u002Fblog\u002F[slug]\u002Fpage.tsx — Server Component\nexport async function generateMetadata({ params }) { ... }\n\nexport default async function Post({ params }) {\n  const post = await getPost(params.slug); \u002F\u002F direct DB\u002FCMS call\n  if (!post) notFound();\n  return \u003Carticle>\u003Ch1>{post.title}\u003C\u002Fh1>\u003CLikeButton id={post.id} \u002F>\u003C\u002Farticle>; \u002F\u002F LikeButton is 'use client'\n}\n```\n\n**3. Client islands.** Interactive pieces (`LikeButton`, forms, charts) become small Client Components receiving props. Never make the whole page `'use client'` for one button.\n\n**4. Mutations via Server Actions.**\n```ts\n'use server';\nexport async function likePost(id: string) {\n  const session = await auth(); if (!session) throw new Error('Unauthorized');\n  await db.like(id, session.user.id);\n  revalidatePath(`\u002Fblog\u002F${id}`);\n}\n```\n\n**5. Caching strategy.** Static marketing pages: default (static). Dashboards: `dynamic = 'force-dynamic'` or `no-store` fetches. Mixed: static shell + Suspense for dynamic islands. Revalidate with tags after mutations.\n\n**6. Deploy.** `next build` → Vercel (zero-config) or Node standalone output \u002F Docker. Set env vars per environment; `next start` for self-hosted.\n\n## Common pitfalls\n\n- **`'use client'` at the page root.** One interactive element drags the whole page to the client. Push the directive to leaves.\n- **Waterfalls.** Sequential awaits in nested Server Components serialize. Parallelize with `Promise.all` or colocate fetches.\n- **Over-fetching in layouts.** Layouts fetch on every navigation within their subtree — keep layout data minimal or cache aggressively.\n- **Cache confusion.** Stale data after mutation = forgot `revalidatePath`\u002F`revalidateTag`. Unwanted caching = fetch defaults. Learn the four cache layers.\n- **Secrets in Client Components.** Anything imported by a client component ships to the browser. Keep keys\u002Fqueries server-side; pass only results as props.\n- **Metadata in client components.** `metadata` exports only work in Server Components. Client pages need a server wrapper for metadata.\n- **`useEffect` for data.** In App Router, data fetching belongs in Server Components, not effects. Effects are for subscriptions\u002FDOM, not initial data.\n- **Ignoring loading.tsx.** Slow server data without Suspense boundaries = blank page until everything resolves. Stream progressively.\n- **Bundle bloat from server imports.** Importing a server-only lib (DB client) into a client component breaks the build or leaks. `server-only` package makes violations fail fast.\n","# Next.js Patterns\n\nA practical guide to Next.js (App Router): the file-system router, Server vs Client Components, data fetching and caching, metadata\u002FSEO, and production deployment patterns.\n\n## Overview\n\nNext.js App Router splits your app into **Server Components** (default: render on the server, zero client JS, direct backend access) and **Client Components** (`'use client'`: interactivity, hooks, browser APIs). The key skill is knowing which to use where: push data fetching and rendering to the server, keep client components small and leaf-ward. Everything else — caching, streaming, metadata — follows from that split.\n\n## When to use\n\n- Full-stack React apps: marketing sites, dashboards, SaaS.\n- SSR\u002FSSG\u002FISR rendering strategies per route.\n- API routes (Route Handlers) colocated with the frontend.\n- Migrating Pages Router → App Router.\n- Optimizing Next.js bundle size and caching behavior.\n\n## Core concepts\n\n- **App Router files.** `app\u002Fpage.tsx` (route UI), `layout.tsx` (shared shell), `loading.tsx` (Suspense fallback), `error.tsx` (error boundary), `not-found.tsx`, `route.ts` (API endpoint), `page.tsx` dynamic via `[slug]`.\n- **Server Components (default).** Async components that fetch directly: `const data = await db.query(...)` in the component. No `useState`\u002F`useEffect`\u002Fbrowser APIs. Ship zero JS for their subtree.\n- **Client Components.** `'use client'` at the top — needed for interactivity. Keep them small; pass server-fetched data as props rather than re-fetching client-side.\n- **Data fetching.** `fetch` in Server Components is cached by default; `cache: 'no-store'` for dynamic, `next: { revalidate: 60 }` for ISR. `generateStaticParams` for static dynamic routes.\n- **Streaming.** `loading.tsx` + `\u003CSuspense>` stream parts of the page as they resolve — fast TTFB with slow data. Wrap slow components, not whole pages.\n- **Server Actions.** `'use server'` functions called from client components — mutations without an API layer. Validate inputs (Zod), check auth, revalidate with `revalidatePath`.\n- **Metadata.** `export const metadata = {...}` \u002F `generateMetadata()` per route — title, description, Open Graph. The SEO story.\n- **Caching layers.** Request memoization → Data Cache → Full Route Cache → Router Cache. Know which layer you're invalidating (`revalidatePath` vs `revalidateTag`).\n\n## Practical workflow\n\n**1. Route structure.**\n```\napp\u002F\n  layout.tsx            # \u003Chtml>, fonts, providers\n  page.tsx              # \u002F\n  blog\u002F[slug]\u002Fpage.tsx  # \u002Fblog\u002F:slug\n  blog\u002F[slug]\u002Floading.tsx\n  dashboard\u002Flayout.tsx  # nested layout\n  api\u002Fwebhooks\u002Froute.ts # API endpoint\n```\n\n**2. Server-first data.**\n```tsx\n\u002F\u002F app\u002Fblog\u002F[slug]\u002Fpage.tsx — Server Component\nexport async function generateMetadata({ params }) { ... }\n\nexport default async function Post({ params }) {\n  const post = await getPost(params.slug); \u002F\u002F direct DB\u002FCMS call\n  if (!post) notFound();\n  return \u003Carticle>\u003Ch1>{post.title}\u003C\u002Fh1>\u003CLikeButton id={post.id} \u002F>\u003C\u002Farticle>; \u002F\u002F LikeButton is 'use client'\n}\n```\n\n**3. Client islands.** Interactive pieces (`LikeButton`, forms, charts) become small Client Components receiving props. Never make the whole page `'use client'` for one button.\n\n**4. Mutations via Server Actions.**\n```ts\n'use server';\nexport async function likePost(id: string) {\n  const session = await auth(); if (!session) throw new Error('Unauthorized');\n  await db.like(id, session.user.id);\n  revalidatePath(`\u002Fblog\u002F${id}`);\n}\n```\n\n**5. Caching strategy.** Static marketing pages: default (static). Dashboards: `dynamic = 'force-dynamic'` or `no-store` fetches. Mixed: static shell + Suspense for dynamic islands. Revalidate with tags after mutations.\n\n**6. Deploy.** `next build` → Vercel (zero-config) or Node standalone output \u002F Docker. Set env vars per environment; `next start` for self-hosted.\n\n## Common pitfalls\n\n- **`'use client'` at the page root.** One interactive element drags the whole page to the client. Push the directive to leaves.\n- **Waterfalls.** Sequential awaits in nested Server Components serialize. Parallelize with `Promise.all` or colocate fetches.\n- **Over-fetching in layouts.** Layouts fetch on every navigation within their subtree — keep layout data minimal or cache aggressively.\n- **Cache confusion.** Stale data after mutation = forgot `revalidatePath`\u002F`revalidateTag`. Unwanted caching = fetch defaults. Learn the four cache layers.\n- **Secrets in Client Components.** Anything imported by a client component ships to the browser. Keep keys\u002Fqueries server-side; pass only results as props.\n- **Metadata in client components.** `metadata` exports only work in Server Components. Client pages need a server wrapper for metadata.\n- **`useEffect` for data.** In App Router, data fetching belongs in Server Components, not effects. Effects are for subscriptions\u002FDOM, not initial data.\n- **Ignoring loading.tsx.** Slow server data without Suspense boundaries = blank page until everything resolves. Stream progressively.\n- **Bundle bloat from server imports.** Importing a server-only lib (DB client) into a client component breaks the build or leaks. `server-only` package makes violations fail fast.\n",{},"main","af388a77c2fe5e0b4fd879cca4300a0ffa9a6579","skills\u002Fams-nextjs-patterns",1,"https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis","https:\u002F\u002Fgithub.com\u002FTanNhatCMS","https:\u002F\u002Fmrkiet.name.vn","2026-11-07 14:23:08",{"source":7,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add TanNhatCMS\u002Fjarvis --skill ams-nextjs-patterns",{"tool":37,"command":38},"bunx","bunx skills add TanNhatCMS\u002Fjarvis --skill ams-nextjs-patterns",{"tool":40,"command":41},"pnpm","pnpm dlx skills add TanNhatCMS\u002Fjarvis --skill ams-nextjs-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fams-nextjs-patterns\u002FSKILL.md",true,[],[46,53,61,68,75,82],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":18},"01M7EWYJR0J8DARY7E59Z6Y9MV","web-scrape","Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open\u002Ffetch fails on JS-heavy pages, or when you need clean markdown\u002Fstructured extraction from a site. Requires FIRECRAWL_API_KEY.","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fweb-scrape\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":57,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":18},"01M7EWYBN5P6F2AJG3FR24T9BP","design-taste-frontend","tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML\u002FCSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, \"AI-made\", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Ftaste-design\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Ftaste-design\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M7EWY8FQFNQ2GB7NZZWGSSDX","test-driven-development","Use when implementing any feature or bugfix, before writing implementation code","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-tdd\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M7EWY5SHBFRH1HDHVWM9K7TV","systematic-debugging","Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-debugging\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M7EWY3NM0Z0JAKS7HDZ24K66","requesting-code-review","Use when completing tasks, implementing major features, or before merging to verify work meets requirements","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-code-review\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":18},"01M7EWY0WRMWX4M9ZFY0WKC593","brainstorming","You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-brainstorming\u002FSKILL.md",[],[]]