@0xsown/vibe-code-fe 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/bin/index.js +181 -0
  2. package/package.json +32 -0
  3. package/skills/claude-md-improver/SKILL.md +179 -0
  4. package/skills/claude-md-improver/references/quality-criteria.md +109 -0
  5. package/skills/claude-md-improver/references/templates.md +253 -0
  6. package/skills/claude-md-improver/references/update-guidelines.md +150 -0
  7. package/skills/find-skills/SKILL.md +133 -0
  8. package/skills/frontend-design/LICENSE.txt +177 -0
  9. package/skills/frontend-design/SKILL.md +42 -0
  10. package/skills/next-best-practices/SKILL.md +153 -0
  11. package/skills/next-best-practices/async-patterns.md +87 -0
  12. package/skills/next-best-practices/bundling.md +180 -0
  13. package/skills/next-best-practices/data-patterns.md +297 -0
  14. package/skills/next-best-practices/debug-tricks.md +105 -0
  15. package/skills/next-best-practices/directives.md +73 -0
  16. package/skills/next-best-practices/error-handling.md +227 -0
  17. package/skills/next-best-practices/file-conventions.md +140 -0
  18. package/skills/next-best-practices/font.md +245 -0
  19. package/skills/next-best-practices/functions.md +108 -0
  20. package/skills/next-best-practices/hydration-error.md +91 -0
  21. package/skills/next-best-practices/image.md +173 -0
  22. package/skills/next-best-practices/metadata.md +301 -0
  23. package/skills/next-best-practices/parallel-routes.md +287 -0
  24. package/skills/next-best-practices/route-handlers.md +146 -0
  25. package/skills/next-best-practices/rsc-boundaries.md +159 -0
  26. package/skills/next-best-practices/runtime-selection.md +39 -0
  27. package/skills/next-best-practices/scripts.md +141 -0
  28. package/skills/next-best-practices/self-hosting.md +371 -0
  29. package/skills/next-best-practices/suspense-boundaries.md +67 -0
  30. package/skills/next-cache-components/SKILL.md +411 -0
  31. package/skills/shadcn-ui/README.md +248 -0
  32. package/skills/shadcn-ui/SKILL.md +326 -0
  33. package/skills/shadcn-ui/examples/auth-layout.tsx +177 -0
  34. package/skills/shadcn-ui/examples/data-table.tsx +313 -0
  35. package/skills/shadcn-ui/examples/form-pattern.tsx +177 -0
  36. package/skills/shadcn-ui/resources/component-catalog.md +481 -0
  37. package/skills/shadcn-ui/resources/customization-guide.md +516 -0
  38. package/skills/shadcn-ui/resources/migration-guide.md +463 -0
  39. package/skills/shadcn-ui/resources/setup-guide.md +412 -0
  40. package/skills/shadcn-ui/scripts/verify-setup.sh +134 -0
  41. package/skills/supabase-postgres-best-practices/AGENTS.md +68 -0
  42. package/skills/supabase-postgres-best-practices/CLAUDE.md +68 -0
  43. package/skills/supabase-postgres-best-practices/README.md +116 -0
  44. package/skills/supabase-postgres-best-practices/SKILL.md +64 -0
  45. package/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
  46. package/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
  47. package/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
  48. package/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
  49. package/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
  50. package/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
  51. package/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
  52. package/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
  53. package/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
  54. package/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
  55. package/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
  56. package/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
  57. package/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
  58. package/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
  59. package/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
  60. package/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
  61. package/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
  62. package/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
  63. package/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
  64. package/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
  65. package/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
  66. package/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
  67. package/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
  68. package/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
  69. package/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
  70. package/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
  71. package/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
  72. package/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
  73. package/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
  74. package/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
  75. package/skills/supabase-postgres-best-practices/references/security-rls-performance.md +57 -0
  76. package/skills/tailwind-design-system/SKILL.md +874 -0
  77. package/skills/vercel-composition-patterns/AGENTS.md +946 -0
  78. package/skills/vercel-composition-patterns/README.md +60 -0
  79. package/skills/vercel-composition-patterns/SKILL.md +89 -0
  80. package/skills/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md +100 -0
  81. package/skills/vercel-composition-patterns/rules/architecture-compound-components.md +112 -0
  82. package/skills/vercel-composition-patterns/rules/patterns-children-over-render-props.md +87 -0
  83. package/skills/vercel-composition-patterns/rules/patterns-explicit-variants.md +100 -0
  84. package/skills/vercel-composition-patterns/rules/react19-no-forwardref.md +42 -0
  85. package/skills/vercel-composition-patterns/rules/state-context-interface.md +191 -0
  86. package/skills/vercel-composition-patterns/rules/state-decouple-implementation.md +113 -0
  87. package/skills/vercel-composition-patterns/rules/state-lift-state.md +125 -0
  88. package/skills/vercel-react-best-practices/AGENTS.md +2934 -0
  89. package/skills/vercel-react-best-practices/README.md +123 -0
  90. package/skills/vercel-react-best-practices/SKILL.md +136 -0
  91. package/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  92. package/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
  93. package/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
  94. package/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
  95. package/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
  96. package/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
  97. package/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
  98. package/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
  99. package/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
  100. package/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
  101. package/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
  102. package/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  103. package/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
  104. package/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
  105. package/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
  106. package/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
  107. package/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
  108. package/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
  109. package/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
  110. package/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
  111. package/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
  112. package/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
  113. package/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
  114. package/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
  115. package/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
  116. package/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
  117. package/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
  118. package/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
  119. package/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
  120. package/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
  121. package/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  122. package/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
  123. package/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
  124. package/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  125. package/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  126. package/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
  127. package/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
  128. package/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
  129. package/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
  130. package/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
  131. package/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
  132. package/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
  133. package/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
  134. package/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  135. package/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
  136. package/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
  137. package/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
  138. package/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
  139. package/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
  140. package/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
  141. package/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
  142. package/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
  143. package/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
  144. package/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
  145. package/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
  146. package/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
  147. package/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
  148. package/skills/vercel-react-native-skills/AGENTS.md +2897 -0
  149. package/skills/vercel-react-native-skills/README.md +165 -0
  150. package/skills/vercel-react-native-skills/SKILL.md +121 -0
  151. package/skills/vercel-react-native-skills/rules/animation-derived-value.md +53 -0
  152. package/skills/vercel-react-native-skills/rules/animation-gesture-detector-press.md +95 -0
  153. package/skills/vercel-react-native-skills/rules/animation-gpu-properties.md +65 -0
  154. package/skills/vercel-react-native-skills/rules/design-system-compound-components.md +66 -0
  155. package/skills/vercel-react-native-skills/rules/fonts-config-plugin.md +71 -0
  156. package/skills/vercel-react-native-skills/rules/imports-design-system-folder.md +68 -0
  157. package/skills/vercel-react-native-skills/rules/js-hoist-intl.md +61 -0
  158. package/skills/vercel-react-native-skills/rules/list-performance-callbacks.md +44 -0
  159. package/skills/vercel-react-native-skills/rules/list-performance-function-references.md +132 -0
  160. package/skills/vercel-react-native-skills/rules/list-performance-images.md +53 -0
  161. package/skills/vercel-react-native-skills/rules/list-performance-inline-objects.md +97 -0
  162. package/skills/vercel-react-native-skills/rules/list-performance-item-expensive.md +94 -0
  163. package/skills/vercel-react-native-skills/rules/list-performance-item-memo.md +82 -0
  164. package/skills/vercel-react-native-skills/rules/list-performance-item-types.md +104 -0
  165. package/skills/vercel-react-native-skills/rules/list-performance-virtualize.md +67 -0
  166. package/skills/vercel-react-native-skills/rules/monorepo-native-deps-in-app.md +46 -0
  167. package/skills/vercel-react-native-skills/rules/monorepo-single-dependency-versions.md +63 -0
  168. package/skills/vercel-react-native-skills/rules/navigation-native-navigators.md +188 -0
  169. package/skills/vercel-react-native-skills/rules/react-compiler-destructure-functions.md +50 -0
  170. package/skills/vercel-react-native-skills/rules/react-compiler-reanimated-shared-values.md +48 -0
  171. package/skills/vercel-react-native-skills/rules/react-state-dispatcher.md +91 -0
  172. package/skills/vercel-react-native-skills/rules/react-state-fallback.md +56 -0
  173. package/skills/vercel-react-native-skills/rules/react-state-minimize.md +65 -0
  174. package/skills/vercel-react-native-skills/rules/rendering-no-falsy-and.md +74 -0
  175. package/skills/vercel-react-native-skills/rules/rendering-text-in-text-component.md +36 -0
  176. package/skills/vercel-react-native-skills/rules/scroll-position-no-state.md +82 -0
  177. package/skills/vercel-react-native-skills/rules/state-ground-truth.md +80 -0
  178. package/skills/vercel-react-native-skills/rules/ui-expo-image.md +66 -0
  179. package/skills/vercel-react-native-skills/rules/ui-image-gallery.md +104 -0
  180. package/skills/vercel-react-native-skills/rules/ui-measure-views.md +78 -0
  181. package/skills/vercel-react-native-skills/rules/ui-menus.md +174 -0
  182. package/skills/vercel-react-native-skills/rules/ui-native-modals.md +77 -0
  183. package/skills/vercel-react-native-skills/rules/ui-pressable.md +61 -0
  184. package/skills/vercel-react-native-skills/rules/ui-safe-area-scroll.md +65 -0
  185. package/skills/vercel-react-native-skills/rules/ui-scrollview-content-inset.md +45 -0
  186. package/skills/vercel-react-native-skills/rules/ui-styling.md +87 -0
  187. package/skills/web-design-guidelines/SKILL.md +39 -0
  188. package/templates/AGENTS.md +31 -0
  189. package/templates/CLAUDE.md +31 -0
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: frontend-design
3
+ description: Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
4
+ license: Complete terms in LICENSE.txt
5
+ ---
6
+
7
+ This skill guides creation of distinctive, production-grade frontend interfaces that avoid generic "AI slop" aesthetics. Implement real working code with exceptional attention to aesthetic details and creative choices.
8
+
9
+ The user provides frontend requirements: a component, page, application, or interface to build. They may include context about the purpose, audience, or technical constraints.
10
+
11
+ ## Design Thinking
12
+
13
+ Before coding, understand the context and commit to a BOLD aesthetic direction:
14
+ - **Purpose**: What problem does this interface solve? Who uses it?
15
+ - **Tone**: Pick an extreme: brutally minimal, maximalist chaos, retro-futuristic, organic/natural, luxury/refined, playful/toy-like, editorial/magazine, brutalist/raw, art deco/geometric, soft/pastel, industrial/utilitarian, etc. There are so many flavors to choose from. Use these for inspiration but design one that is true to the aesthetic direction.
16
+ - **Constraints**: Technical requirements (framework, performance, accessibility).
17
+ - **Differentiation**: What makes this UNFORGETTABLE? What's the one thing someone will remember?
18
+
19
+ **CRITICAL**: Choose a clear conceptual direction and execute it with precision. Bold maximalism and refined minimalism both work - the key is intentionality, not intensity.
20
+
21
+ Then implement working code (HTML/CSS/JS, React, Vue, etc.) that is:
22
+ - Production-grade and functional
23
+ - Visually striking and memorable
24
+ - Cohesive with a clear aesthetic point-of-view
25
+ - Meticulously refined in every detail
26
+
27
+ ## Frontend Aesthetics Guidelines
28
+
29
+ Focus on:
30
+ - **Typography**: Choose fonts that are beautiful, unique, and interesting. Avoid generic fonts like Arial and Inter; opt instead for distinctive choices that elevate the frontend's aesthetics; unexpected, characterful font choices. Pair a distinctive display font with a refined body font.
31
+ - **Color & Theme**: Commit to a cohesive aesthetic. Use CSS variables for consistency. Dominant colors with sharp accents outperform timid, evenly-distributed palettes.
32
+ - **Motion**: Use animations for effects and micro-interactions. Prioritize CSS-only solutions for HTML. Use Motion library for React when available. Focus on high-impact moments: one well-orchestrated page load with staggered reveals (animation-delay) creates more delight than scattered micro-interactions. Use scroll-triggering and hover states that surprise.
33
+ - **Spatial Composition**: Unexpected layouts. Asymmetry. Overlap. Diagonal flow. Grid-breaking elements. Generous negative space OR controlled density.
34
+ - **Backgrounds & Visual Details**: Create atmosphere and depth rather than defaulting to solid colors. Add contextual effects and textures that match the overall aesthetic. Apply creative forms like gradient meshes, noise textures, geometric patterns, layered transparencies, dramatic shadows, decorative borders, custom cursors, and grain overlays.
35
+
36
+ NEVER use generic AI-generated aesthetics like overused font families (Inter, Roboto, Arial, system fonts), cliched color schemes (particularly purple gradients on white backgrounds), predictable layouts and component patterns, and cookie-cutter design that lacks context-specific character.
37
+
38
+ Interpret creatively and make unexpected choices that feel genuinely designed for the context. No design should be the same. Vary between light and dark themes, different fonts, different aesthetics. NEVER converge on common choices (Space Grotesk, for example) across generations.
39
+
40
+ **IMPORTANT**: Match implementation complexity to the aesthetic vision. Maximalist designs need elaborate code with extensive animations and effects. Minimalist or refined designs need restraint, precision, and careful attention to spacing, typography, and subtle details. Elegance comes from executing the vision well.
41
+
42
+ Remember: Claude is capable of extraordinary creative work. Don't hold back, show what can truly be created when thinking outside the box and committing fully to a distinctive vision.
@@ -0,0 +1,153 @@
1
+ ---
2
+ name: next-best-practices
3
+ description: Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling
4
+ user-invocable: false
5
+ ---
6
+
7
+ # Next.js Best Practices
8
+
9
+ Apply these rules when writing or reviewing Next.js code.
10
+
11
+ ## File Conventions
12
+
13
+ See [file-conventions.md](./file-conventions.md) for:
14
+ - Project structure and special files
15
+ - Route segments (dynamic, catch-all, groups)
16
+ - Parallel and intercepting routes
17
+ - Middleware rename in v16 (middleware → proxy)
18
+
19
+ ## RSC Boundaries
20
+
21
+ Detect invalid React Server Component patterns.
22
+
23
+ See [rsc-boundaries.md](./rsc-boundaries.md) for:
24
+ - Async client component detection (invalid)
25
+ - Non-serializable props detection
26
+ - Server Action exceptions
27
+
28
+ ## Async Patterns
29
+
30
+ Next.js 15+ async API changes.
31
+
32
+ See [async-patterns.md](./async-patterns.md) for:
33
+ - Async `params` and `searchParams`
34
+ - Async `cookies()` and `headers()`
35
+ - Migration codemod
36
+
37
+ ## Runtime Selection
38
+
39
+ See [runtime-selection.md](./runtime-selection.md) for:
40
+ - Default to Node.js runtime
41
+ - When Edge runtime is appropriate
42
+
43
+ ## Directives
44
+
45
+ See [directives.md](./directives.md) for:
46
+ - `'use client'`, `'use server'` (React)
47
+ - `'use cache'` (Next.js)
48
+
49
+ ## Functions
50
+
51
+ See [functions.md](./functions.md) for:
52
+ - Navigation hooks: `useRouter`, `usePathname`, `useSearchParams`, `useParams`
53
+ - Server functions: `cookies`, `headers`, `draftMode`, `after`
54
+ - Generate functions: `generateStaticParams`, `generateMetadata`
55
+
56
+ ## Error Handling
57
+
58
+ See [error-handling.md](./error-handling.md) for:
59
+ - `error.tsx`, `global-error.tsx`, `not-found.tsx`
60
+ - `redirect`, `permanentRedirect`, `notFound`
61
+ - `forbidden`, `unauthorized` (auth errors)
62
+ - `unstable_rethrow` for catch blocks
63
+
64
+ ## Data Patterns
65
+
66
+ See [data-patterns.md](./data-patterns.md) for:
67
+ - Server Components vs Server Actions vs Route Handlers
68
+ - Avoiding data waterfalls (`Promise.all`, Suspense, preload)
69
+ - Client component data fetching
70
+
71
+ ## Route Handlers
72
+
73
+ See [route-handlers.md](./route-handlers.md) for:
74
+ - `route.ts` basics
75
+ - GET handler conflicts with `page.tsx`
76
+ - Environment behavior (no React DOM)
77
+ - When to use vs Server Actions
78
+
79
+ ## Metadata & OG Images
80
+
81
+ See [metadata.md](./metadata.md) for:
82
+ - Static and dynamic metadata
83
+ - `generateMetadata` function
84
+ - OG image generation with `next/og`
85
+ - File-based metadata conventions
86
+
87
+ ## Image Optimization
88
+
89
+ See [image.md](./image.md) for:
90
+ - Always use `next/image` over `<img>`
91
+ - Remote images configuration
92
+ - Responsive `sizes` attribute
93
+ - Blur placeholders
94
+ - Priority loading for LCP
95
+
96
+ ## Font Optimization
97
+
98
+ See [font.md](./font.md) for:
99
+ - `next/font` setup
100
+ - Google Fonts, local fonts
101
+ - Tailwind CSS integration
102
+ - Preloading subsets
103
+
104
+ ## Bundling
105
+
106
+ See [bundling.md](./bundling.md) for:
107
+ - Server-incompatible packages
108
+ - CSS imports (not link tags)
109
+ - Polyfills (already included)
110
+ - ESM/CommonJS issues
111
+ - Bundle analysis
112
+
113
+ ## Scripts
114
+
115
+ See [scripts.md](./scripts.md) for:
116
+ - `next/script` vs native script tags
117
+ - Inline scripts need `id`
118
+ - Loading strategies
119
+ - Google Analytics with `@next/third-parties`
120
+
121
+ ## Hydration Errors
122
+
123
+ See [hydration-error.md](./hydration-error.md) for:
124
+ - Common causes (browser APIs, dates, invalid HTML)
125
+ - Debugging with error overlay
126
+ - Fixes for each cause
127
+
128
+ ## Suspense Boundaries
129
+
130
+ See [suspense-boundaries.md](./suspense-boundaries.md) for:
131
+ - CSR bailout with `useSearchParams` and `usePathname`
132
+ - Which hooks require Suspense boundaries
133
+
134
+ ## Parallel & Intercepting Routes
135
+
136
+ See [parallel-routes.md](./parallel-routes.md) for:
137
+ - Modal patterns with `@slot` and `(.)` interceptors
138
+ - `default.tsx` for fallbacks
139
+ - Closing modals correctly with `router.back()`
140
+
141
+ ## Self-Hosting
142
+
143
+ See [self-hosting.md](./self-hosting.md) for:
144
+ - `output: 'standalone'` for Docker
145
+ - Cache handlers for multi-instance ISR
146
+ - What works vs needs extra setup
147
+
148
+ ## Debug Tricks
149
+
150
+ See [debug-tricks.md](./debug-tricks.md) for:
151
+ - MCP endpoint for AI-assisted debugging
152
+ - Rebuild specific routes with `--debug-build-paths`
153
+
@@ -0,0 +1,87 @@
1
+ # Async Patterns
2
+
3
+ In Next.js 15+, `params`, `searchParams`, `cookies()`, and `headers()` are asynchronous.
4
+
5
+ ## Async Params and SearchParams
6
+
7
+ Always type them as `Promise<...>` and await them.
8
+
9
+ ### Pages and Layouts
10
+
11
+ ```tsx
12
+ type Props = { params: Promise<{ slug: string }> }
13
+
14
+ export default async function Page({ params }: Props) {
15
+ const { slug } = await params
16
+ }
17
+ ```
18
+
19
+ ### Route Handlers
20
+
21
+ ```tsx
22
+ export async function GET(
23
+ request: Request,
24
+ { params }: { params: Promise<{ id: string }> }
25
+ ) {
26
+ const { id } = await params
27
+ }
28
+ ```
29
+
30
+ ### SearchParams
31
+
32
+ ```tsx
33
+ type Props = {
34
+ params: Promise<{ slug: string }>
35
+ searchParams: Promise<{ query?: string }>
36
+ }
37
+
38
+ export default async function Page({ params, searchParams }: Props) {
39
+ const { slug } = await params
40
+ const { query } = await searchParams
41
+ }
42
+ ```
43
+
44
+ ### Synchronous Components
45
+
46
+ Use `React.use()` for non-async components:
47
+
48
+ ```tsx
49
+ import { use } from 'react'
50
+
51
+ type Props = { params: Promise<{ slug: string }> }
52
+
53
+ export default function Page({ params }: Props) {
54
+ const { slug } = use(params)
55
+ }
56
+ ```
57
+
58
+ ### generateMetadata
59
+
60
+ ```tsx
61
+ type Props = { params: Promise<{ slug: string }> }
62
+
63
+ export async function generateMetadata({ params }: Props): Promise<Metadata> {
64
+ const { slug } = await params
65
+ return { title: slug }
66
+ }
67
+ ```
68
+
69
+ ## Async Cookies and Headers
70
+
71
+ ```tsx
72
+ import { cookies, headers } from 'next/headers'
73
+
74
+ export default async function Page() {
75
+ const cookieStore = await cookies()
76
+ const headersList = await headers()
77
+
78
+ const theme = cookieStore.get('theme')
79
+ const userAgent = headersList.get('user-agent')
80
+ }
81
+ ```
82
+
83
+ ## Migration Codemod
84
+
85
+ ```bash
86
+ npx @next/codemod@latest next-async-request-api .
87
+ ```
@@ -0,0 +1,180 @@
1
+ # Bundling
2
+
3
+ Fix common bundling issues with third-party packages.
4
+
5
+ ## Server-Incompatible Packages
6
+
7
+ Some packages use browser APIs (`window`, `document`, `localStorage`) and fail in Server Components.
8
+
9
+ ### Error Signs
10
+
11
+ ```
12
+ ReferenceError: window is not defined
13
+ ReferenceError: document is not defined
14
+ ReferenceError: localStorage is not defined
15
+ Module not found: Can't resolve 'fs'
16
+ ```
17
+
18
+ ### Solution 1: Mark as Client-Only
19
+
20
+ If the package is only needed on client:
21
+
22
+ ```tsx
23
+ // Bad: Fails - package uses window
24
+ import SomeChart from 'some-chart-library'
25
+
26
+ export default function Page() {
27
+ return <SomeChart />
28
+ }
29
+
30
+ // Good: Use dynamic import with ssr: false
31
+ import dynamic from 'next/dynamic'
32
+
33
+ const SomeChart = dynamic(() => import('some-chart-library'), {
34
+ ssr: false,
35
+ })
36
+
37
+ export default function Page() {
38
+ return <SomeChart />
39
+ }
40
+ ```
41
+
42
+ ### Solution 2: Externalize from Server Bundle
43
+
44
+ For packages that should run on server but have bundling issues:
45
+
46
+ ```js
47
+ // next.config.js
48
+ module.exports = {
49
+ serverExternalPackages: ['problematic-package'],
50
+ }
51
+ ```
52
+
53
+ Use this for:
54
+ - Packages with native bindings (sharp, bcrypt)
55
+ - Packages that don't bundle well (some ORMs)
56
+ - Packages with circular dependencies
57
+
58
+ ### Solution 3: Client Component Wrapper
59
+
60
+ Wrap the entire usage in a client component:
61
+
62
+ ```tsx
63
+ // components/ChartWrapper.tsx
64
+ 'use client'
65
+
66
+ import { Chart } from 'chart-library'
67
+
68
+ export function ChartWrapper(props) {
69
+ return <Chart {...props} />
70
+ }
71
+
72
+ // app/page.tsx (server component)
73
+ import { ChartWrapper } from '@/components/ChartWrapper'
74
+
75
+ export default function Page() {
76
+ return <ChartWrapper data={data} />
77
+ }
78
+ ```
79
+
80
+ ## CSS Imports
81
+
82
+ Import CSS files instead of using `<link>` tags. Next.js handles bundling and optimization.
83
+
84
+ ```tsx
85
+ // Bad: Manual link tag
86
+ <link rel="stylesheet" href="/styles.css" />
87
+
88
+ // Good: Import CSS
89
+ import './styles.css'
90
+
91
+ // Good: CSS Modules
92
+ import styles from './Button.module.css'
93
+ ```
94
+
95
+ ## Polyfills
96
+
97
+ Next.js includes common polyfills automatically. Don't load redundant ones from polyfill.io or similar CDNs.
98
+
99
+ Already included: `Array.from`, `Object.assign`, `Promise`, `fetch`, `Map`, `Set`, `Symbol`, `URLSearchParams`, and 50+ others.
100
+
101
+ ```tsx
102
+ // Bad: Redundant polyfills
103
+ <script src="https://polyfill.io/v3/polyfill.min.js?features=fetch,Promise,Array.from" />
104
+
105
+ // Good: Next.js includes these automatically
106
+ ```
107
+
108
+ ## ESM/CommonJS Issues
109
+
110
+ ### Error Signs
111
+
112
+ ```
113
+ SyntaxError: Cannot use import statement outside a module
114
+ Error: require() of ES Module
115
+ Module not found: ESM packages need to be imported
116
+ ```
117
+
118
+ ### Solution: Transpile Package
119
+
120
+ ```js
121
+ // next.config.js
122
+ module.exports = {
123
+ transpilePackages: ['some-esm-package', 'another-package'],
124
+ }
125
+ ```
126
+
127
+ ## Common Problematic Packages
128
+
129
+ | Package | Issue | Solution |
130
+ |---------|-------|----------|
131
+ | `sharp` | Native bindings | `serverExternalPackages: ['sharp']` |
132
+ | `bcrypt` | Native bindings | `serverExternalPackages: ['bcrypt']` or use `bcryptjs` |
133
+ | `canvas` | Native bindings | `serverExternalPackages: ['canvas']` |
134
+ | `recharts` | Uses window | `dynamic(() => import('recharts'), { ssr: false })` |
135
+ | `react-quill` | Uses document | `dynamic(() => import('react-quill'), { ssr: false })` |
136
+ | `mapbox-gl` | Uses window | `dynamic(() => import('mapbox-gl'), { ssr: false })` |
137
+ | `monaco-editor` | Uses window | `dynamic(() => import('@monaco-editor/react'), { ssr: false })` |
138
+ | `lottie-web` | Uses document | `dynamic(() => import('lottie-react'), { ssr: false })` |
139
+
140
+ ## Bundle Analysis
141
+
142
+ Analyze bundle size with the built-in analyzer (Next.js 16.1+):
143
+
144
+ ```bash
145
+ next experimental-analyze
146
+ ```
147
+
148
+ This opens an interactive UI to:
149
+ - Filter by route, environment (client/server), and type
150
+ - Inspect module sizes and import chains
151
+ - View treemap visualization
152
+
153
+ Save output for comparison:
154
+
155
+ ```bash
156
+ next experimental-analyze --output
157
+ # Output saved to .next/diagnostics/analyze
158
+ ```
159
+
160
+ Reference: https://nextjs.org/docs/app/guides/package-bundling
161
+
162
+ ## Migrating from Webpack to Turbopack
163
+
164
+ Turbopack is the default bundler in Next.js 15+. If you have custom webpack config, migrate to Turbopack-compatible alternatives:
165
+
166
+ ```js
167
+ // next.config.js
168
+ module.exports = {
169
+ // Good: Works with Turbopack
170
+ serverExternalPackages: ['package'],
171
+ transpilePackages: ['package'],
172
+
173
+ // Bad: Webpack-only - migrate away from this
174
+ webpack: (config) => {
175
+ // custom webpack config
176
+ },
177
+ }
178
+ ```
179
+
180
+ Reference: https://nextjs.org/docs/app/building-your-application/upgrading/from-webpack-to-turbopack