create-huenei-template 0.2.13 → 0.2.15

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 (432) hide show
  1. package/dist/config/templates.js +7 -0
  2. package/dist/templates/cursor/.cursor/agents/config-drift-analyzer.md +152 -0
  3. package/dist/templates/cursor/.cursor/commands/actualizar-reglas.md +580 -0
  4. package/dist/templates/frontend/react-ssr/.cursor/agents/accessibility-reviewer.md +22 -0
  5. package/dist/templates/frontend/react-ssr/.cursor/agents/nextjs-code-reviewer.md +24 -0
  6. package/dist/templates/frontend/react-ssr/.cursor/agents/react-test-expert.md +32 -0
  7. package/dist/templates/frontend/react-ssr/.cursor/agents/security-auditor.md +25 -0
  8. package/dist/templates/frontend/react-ssr/.cursor/commands/new-component.md +97 -0
  9. package/dist/templates/frontend/react-ssr/.cursor/commands/new-page.md +95 -0
  10. package/dist/templates/frontend/react-ssr/.cursor/commands/new-prisma-model.md +66 -0
  11. package/dist/templates/frontend/react-ssr/.cursor/commands/new-server-action.md +89 -0
  12. package/dist/templates/frontend/react-ssr/.cursor/hooks/auto-format.ts +64 -0
  13. package/dist/templates/frontend/react-ssr/.cursor/hooks/auto-test-on-stop.ts +94 -0
  14. package/dist/templates/frontend/react-ssr/.cursor/hooks/block-dangerous-commands.ts +120 -0
  15. package/dist/templates/frontend/react-ssr/.cursor/hooks/ensure-tests-exist.ts +209 -0
  16. package/dist/templates/frontend/react-ssr/.cursor/hooks/protect-sensitive-files.ts +101 -0
  17. package/dist/templates/frontend/react-ssr/.cursor/hooks/session-context.ts +93 -0
  18. package/dist/templates/frontend/react-ssr/.cursor/hooks/tsconfig.json +10 -0
  19. package/dist/templates/frontend/react-ssr/.cursor/hooks.json +41 -0
  20. package/dist/templates/frontend/react-ssr/.cursor/rules/auth-patterns.mdc +48 -0
  21. package/dist/templates/frontend/react-ssr/.cursor/rules/code-quality.mdc +39 -0
  22. package/dist/templates/frontend/react-ssr/.cursor/rules/naming-conventions.mdc +32 -0
  23. package/dist/templates/frontend/react-ssr/.cursor/rules/nextjs-architecture.mdc +51 -0
  24. package/dist/templates/frontend/react-ssr/.cursor/rules/prisma-standards.mdc +53 -0
  25. package/dist/templates/frontend/react-ssr/.cursor/rules/react-conventions.mdc +52 -0
  26. package/dist/templates/frontend/react-ssr/.cursor/rules/testing-conventions.mdc +53 -0
  27. package/dist/templates/frontend/react-ssr/.cursor/rules/ui-stack.mdc +47 -0
  28. package/dist/templates/frontend/react-ssr/.cursor/skills/authjs-skills/SKILL.md +1149 -0
  29. package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/SKILL.md +189 -0
  30. package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/daisyUI5.skill +0 -0
  31. package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/creating-components.md +412 -0
  32. package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/data-display.md +341 -0
  33. package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/feedback.md +240 -0
  34. package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/input.md +283 -0
  35. package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/layout.md +275 -0
  36. package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/navigation.md +338 -0
  37. package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/daisy-meta.ts +220 -0
  38. package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/generate-daisy-safelist.ts +152 -0
  39. package/dist/templates/frontend/react-ssr/.cursor/skills/docker-expert/SKILL.md +413 -0
  40. package/dist/templates/frontend/react-ssr/.cursor/skills/nextjs-app-router-patterns/SKILL.md +537 -0
  41. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/SKILL.md +243 -0
  42. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-execute.md +75 -0
  43. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-pull.md +185 -0
  44. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-push.md +148 -0
  45. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-seed.md +191 -0
  46. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/debug.md +46 -0
  47. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/dev.md +157 -0
  48. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/format.md +48 -0
  49. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/generate.md +147 -0
  50. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/init.md +118 -0
  51. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-deploy.md +127 -0
  52. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-dev.md +143 -0
  53. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-diff.md +89 -0
  54. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-reset.md +72 -0
  55. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-resolve.md +57 -0
  56. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-status.md +65 -0
  57. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/studio.md +122 -0
  58. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/validate.md +53 -0
  59. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/SKILL.md +216 -0
  60. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/client-methods.md +221 -0
  61. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/constructor.md +185 -0
  62. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/filters.md +256 -0
  63. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/model-queries.md +281 -0
  64. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/query-options.md +276 -0
  65. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/raw-queries.md +194 -0
  66. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/relations.md +308 -0
  67. package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/transactions.md +184 -0
  68. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/AGENTS.md +97 -0
  69. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/README.md +138 -0
  70. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/SKILL.md +116 -0
  71. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/assets/templates/_template.md +26 -0
  72. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/_sections.md +46 -0
  73. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-devtools-performance.md +69 -0
  74. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-formprovider-memo.md +78 -0
  75. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-testing-wrapper.md +63 -0
  76. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-complete-default-objects.md +66 -0
  77. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-separate-crud-operations.md +76 -0
  78. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-unique-fieldarray-per-name.md +58 -0
  79. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-use-field-id-as-key.md +54 -0
  80. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-virtualization-formprovider.md +64 -0
  81. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-avoid-double-registration.md +46 -0
  82. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-controller-field-props.md +56 -0
  83. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-local-state-combination.md +69 -0
  84. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-single-usecontroller-per-component.md +62 -0
  85. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-usecontroller-isolation.md +64 -0
  86. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-async-default-values.md +69 -0
  87. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-default-values.md +57 -0
  88. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-revalidate-mode.md +48 -0
  89. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-should-unregister.md +62 -0
  90. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-useeffect-dependency.md +54 -0
  91. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-validation-mode.md +51 -0
  92. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-avoid-isvalid-with-onsubmit.md +58 -0
  93. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-destructure-formstate.md +48 -0
  94. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-getfieldstate-for-single-field.md +49 -0
  95. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-subscribe-to-specific-fields.md +54 -0
  96. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-useformstate-isolation.md +62 -0
  97. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-mui-controller-pattern.md +59 -0
  98. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-form-import.md +64 -0
  99. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-select-wiring.md +64 -0
  100. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-value-transform.md +59 -0
  101. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-avoid-watch-in-render.md +48 -0
  102. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-deep-subscription.md +62 -0
  103. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-useformcontext-sparingly.md +58 -0
  104. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-default-value.md +50 -0
  105. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-over-watch.md +58 -0
  106. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-with-getvalues.md +54 -0
  107. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-watch-specific-fields.md +54 -0
  108. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-delay-error.md +52 -0
  109. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-dynamic-schema-factory.md +57 -0
  110. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-error-message-strategy.md +65 -0
  111. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-inline-vs-resolver.md +63 -0
  112. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-native-validation.md +60 -0
  113. package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-resolver-caching.md +58 -0
  114. package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/SKILL.md +713 -0
  115. package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/api_reference.md +1121 -0
  116. package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/best_practices.md +782 -0
  117. package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/examples.md +940 -0
  118. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/SKILL.md +114 -0
  119. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-gc-time.md +93 -0
  120. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-invalidation.md +116 -0
  121. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-placeholder-vs-initial.md +156 -0
  122. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-stale-time.md +80 -0
  123. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/err-error-boundaries.md +150 -0
  124. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/inf-page-params.md +132 -0
  125. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-invalidate-queries.md +118 -0
  126. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-mutation-state.md +169 -0
  127. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-optimistic-updates.md +137 -0
  128. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/network-mode.md +179 -0
  129. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/parallel-use-queries.md +152 -0
  130. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/perf-select-transform.md +144 -0
  131. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/persist-queries.md +194 -0
  132. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/pf-intent-prefetch.md +143 -0
  133. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-array-structure.md +50 -0
  134. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-factory-pattern.md +102 -0
  135. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-hierarchical-organization.md +76 -0
  136. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-include-dependencies.md +62 -0
  137. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-serializable.md +93 -0
  138. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/query-cancellation.md +171 -0
  139. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/ssr-dehydration.md +158 -0
  140. package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-table/SKILL.md +582 -0
  141. package/dist/templates/frontend/react-ssr/.cursor/skills/zod-4/SKILL.md +216 -0
  142. package/dist/templates/frontend/react-ssr/.dockerignore +14 -0
  143. package/dist/templates/frontend/react-ssr/.env.example +9 -0
  144. package/dist/templates/frontend/react-ssr/.husky/pre-commit +1 -0
  145. package/dist/templates/frontend/react-ssr/Dockerfile +41 -0
  146. package/dist/templates/frontend/react-ssr/README.md +121 -0
  147. package/dist/templates/frontend/react-ssr/components.json +22 -0
  148. package/dist/templates/frontend/react-ssr/docker-compose.yml +21 -0
  149. package/dist/templates/frontend/react-ssr/eslint.config.mjs +26 -0
  150. package/dist/templates/frontend/react-ssr/next.config.ts +7 -0
  151. package/dist/templates/frontend/react-ssr/package.json +86 -0
  152. package/dist/templates/frontend/react-ssr/postcss.config.mjs +5 -0
  153. package/dist/templates/frontend/react-ssr/prisma/schema.prisma +75 -0
  154. package/dist/templates/frontend/react-ssr/prisma/seed.ts +109 -0
  155. package/dist/templates/frontend/react-ssr/prisma.config.ts +17 -0
  156. package/dist/templates/frontend/react-ssr/skills-lock.json +65 -0
  157. package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/badge.test.tsx +26 -0
  158. package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/button.test.tsx +38 -0
  159. package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/card.test.tsx +39 -0
  160. package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/input.test.tsx +32 -0
  161. package/dist/templates/frontend/react-ssr/src/__tests__/hooks/useLocalStorage.test.ts +53 -0
  162. package/dist/templates/frontend/react-ssr/src/__tests__/lib/queryClient.test.ts +19 -0
  163. package/dist/templates/frontend/react-ssr/src/__tests__/lib/utils.test.ts +24 -0
  164. package/dist/templates/frontend/react-ssr/src/actions/auth.ts +91 -0
  165. package/dist/templates/frontend/react-ssr/src/actions/contacto.ts +46 -0
  166. package/dist/templates/frontend/react-ssr/src/actions/proyectos.ts +159 -0
  167. package/dist/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/dashboard-client.tsx +321 -0
  168. package/dist/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/page.tsx +48 -0
  169. package/dist/templates/frontend/react-ssr/src/app/(authenticated)/layout.tsx +34 -0
  170. package/dist/templates/frontend/react-ssr/src/app/(authenticated)/perfil/page.tsx +85 -0
  171. package/dist/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/page.tsx +23 -0
  172. package/dist/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/proyectos-crud-client.tsx +472 -0
  173. package/dist/templates/frontend/react-ssr/src/app/(authenticated)/ui-components/page.tsx +358 -0
  174. package/dist/templates/frontend/react-ssr/src/app/api/auth/[...nextauth]/route.ts +3 -0
  175. package/dist/templates/frontend/react-ssr/src/app/auth/iniciar-sesion/page.tsx +148 -0
  176. package/dist/templates/frontend/react-ssr/src/app/auth/recuperar-password/page.tsx +100 -0
  177. package/dist/templates/frontend/react-ssr/src/app/auth/registro/page.tsx +154 -0
  178. package/dist/templates/frontend/react-ssr/src/app/contacto/contacto-form.tsx +189 -0
  179. package/dist/templates/frontend/react-ssr/src/app/contacto/page.tsx +11 -0
  180. package/dist/templates/frontend/react-ssr/src/app/globals.css +99 -0
  181. package/dist/templates/frontend/react-ssr/src/app/layout.tsx +22 -0
  182. package/dist/templates/frontend/react-ssr/src/app/loading.tsx +7 -0
  183. package/dist/templates/frontend/react-ssr/src/app/not-found.tsx +14 -0
  184. package/dist/templates/frontend/react-ssr/src/app/page.tsx +331 -0
  185. package/dist/templates/frontend/react-ssr/src/app/proyectos/page.tsx +178 -0
  186. package/dist/templates/frontend/react-ssr/src/auth.ts +64 -0
  187. package/dist/templates/frontend/react-ssr/src/components/layout/navbar.tsx +68 -0
  188. package/dist/templates/frontend/react-ssr/src/components/layout/sidebar.tsx +109 -0
  189. package/dist/templates/frontend/react-ssr/src/components/layout/sign-out-button.tsx +16 -0
  190. package/dist/templates/frontend/react-ssr/src/components/providers.tsx +33 -0
  191. package/dist/templates/frontend/react-ssr/src/components/ui/avatar.tsx +53 -0
  192. package/dist/templates/frontend/react-ssr/src/components/ui/badge.tsx +42 -0
  193. package/dist/templates/frontend/react-ssr/src/components/ui/breadcrumb.tsx +114 -0
  194. package/dist/templates/frontend/react-ssr/src/components/ui/button.tsx +58 -0
  195. package/dist/templates/frontend/react-ssr/src/components/ui/card.tsx +95 -0
  196. package/dist/templates/frontend/react-ssr/src/components/ui/dialog.tsx +136 -0
  197. package/dist/templates/frontend/react-ssr/src/components/ui/form.tsx +168 -0
  198. package/dist/templates/frontend/react-ssr/src/components/ui/input.tsx +22 -0
  199. package/dist/templates/frontend/react-ssr/src/components/ui/label.tsx +26 -0
  200. package/dist/templates/frontend/react-ssr/src/components/ui/password-input.tsx +43 -0
  201. package/dist/templates/frontend/react-ssr/src/components/ui/separator.tsx +30 -0
  202. package/dist/templates/frontend/react-ssr/src/components/ui/table.tsx +240 -0
  203. package/dist/templates/frontend/react-ssr/src/components/ui/tabs.tsx +76 -0
  204. package/dist/templates/frontend/react-ssr/src/components/ui/textarea.tsx +21 -0
  205. package/dist/templates/frontend/react-ssr/src/data/dashboard.ts +179 -0
  206. package/dist/templates/frontend/react-ssr/src/hooks/useLocalStorage.ts +38 -0
  207. package/dist/templates/frontend/react-ssr/src/lib/prisma.ts +24 -0
  208. package/dist/templates/frontend/react-ssr/src/lib/queryClient.ts +25 -0
  209. package/dist/templates/frontend/react-ssr/src/lib/utils.ts +6 -0
  210. package/dist/templates/frontend/react-ssr/src/proxy.ts +31 -0
  211. package/dist/templates/frontend/react-ssr/src/test/mocks/next-navigation.ts +16 -0
  212. package/dist/templates/frontend/react-ssr/src/test/setup.ts +1 -0
  213. package/dist/templates/frontend/react-ssr/src/test/utils.tsx +30 -0
  214. package/dist/templates/frontend/react-ssr/src/types/index.ts +36 -0
  215. package/dist/templates/frontend/react-ssr/tsconfig.json +41 -0
  216. package/dist/templates/frontend/react-ssr/vitest.config.ts +41 -0
  217. package/package.json +1 -1
  218. package/templates/cursor/.cursor/agents/config-drift-analyzer.md +152 -0
  219. package/templates/cursor/.cursor/commands/actualizar-reglas.md +580 -0
  220. package/templates/frontend/react-ssr/.cursor/agents/accessibility-reviewer.md +22 -0
  221. package/templates/frontend/react-ssr/.cursor/agents/nextjs-code-reviewer.md +24 -0
  222. package/templates/frontend/react-ssr/.cursor/agents/react-test-expert.md +32 -0
  223. package/templates/frontend/react-ssr/.cursor/agents/security-auditor.md +25 -0
  224. package/templates/frontend/react-ssr/.cursor/commands/new-component.md +97 -0
  225. package/templates/frontend/react-ssr/.cursor/commands/new-page.md +95 -0
  226. package/templates/frontend/react-ssr/.cursor/commands/new-prisma-model.md +66 -0
  227. package/templates/frontend/react-ssr/.cursor/commands/new-server-action.md +89 -0
  228. package/templates/frontend/react-ssr/.cursor/hooks/auto-format.ts +64 -0
  229. package/templates/frontend/react-ssr/.cursor/hooks/auto-test-on-stop.ts +94 -0
  230. package/templates/frontend/react-ssr/.cursor/hooks/block-dangerous-commands.ts +120 -0
  231. package/templates/frontend/react-ssr/.cursor/hooks/ensure-tests-exist.ts +209 -0
  232. package/templates/frontend/react-ssr/.cursor/hooks/protect-sensitive-files.ts +101 -0
  233. package/templates/frontend/react-ssr/.cursor/hooks/session-context.ts +93 -0
  234. package/templates/frontend/react-ssr/.cursor/hooks/tsconfig.json +10 -0
  235. package/templates/frontend/react-ssr/.cursor/hooks.json +41 -0
  236. package/templates/frontend/react-ssr/.cursor/rules/auth-patterns.mdc +48 -0
  237. package/templates/frontend/react-ssr/.cursor/rules/code-quality.mdc +39 -0
  238. package/templates/frontend/react-ssr/.cursor/rules/naming-conventions.mdc +32 -0
  239. package/templates/frontend/react-ssr/.cursor/rules/nextjs-architecture.mdc +51 -0
  240. package/templates/frontend/react-ssr/.cursor/rules/prisma-standards.mdc +53 -0
  241. package/templates/frontend/react-ssr/.cursor/rules/react-conventions.mdc +52 -0
  242. package/templates/frontend/react-ssr/.cursor/rules/testing-conventions.mdc +53 -0
  243. package/templates/frontend/react-ssr/.cursor/rules/ui-stack.mdc +47 -0
  244. package/templates/frontend/react-ssr/.cursor/skills/authjs-skills/SKILL.md +1149 -0
  245. package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/SKILL.md +189 -0
  246. package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/daisyUI5.skill +0 -0
  247. package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/creating-components.md +412 -0
  248. package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/data-display.md +341 -0
  249. package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/feedback.md +240 -0
  250. package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/input.md +283 -0
  251. package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/layout.md +275 -0
  252. package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/navigation.md +338 -0
  253. package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/daisy-meta.ts +220 -0
  254. package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/generate-daisy-safelist.ts +152 -0
  255. package/templates/frontend/react-ssr/.cursor/skills/docker-expert/SKILL.md +413 -0
  256. package/templates/frontend/react-ssr/.cursor/skills/nextjs-app-router-patterns/SKILL.md +537 -0
  257. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/SKILL.md +243 -0
  258. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-execute.md +75 -0
  259. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-pull.md +185 -0
  260. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-push.md +148 -0
  261. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-seed.md +191 -0
  262. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/debug.md +46 -0
  263. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/dev.md +157 -0
  264. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/format.md +48 -0
  265. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/generate.md +147 -0
  266. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/init.md +118 -0
  267. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-deploy.md +127 -0
  268. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-dev.md +143 -0
  269. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-diff.md +89 -0
  270. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-reset.md +72 -0
  271. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-resolve.md +57 -0
  272. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-status.md +65 -0
  273. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/studio.md +122 -0
  274. package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/validate.md +53 -0
  275. package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/SKILL.md +216 -0
  276. package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/client-methods.md +221 -0
  277. package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/constructor.md +185 -0
  278. package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/filters.md +256 -0
  279. package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/model-queries.md +281 -0
  280. package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/query-options.md +276 -0
  281. package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/raw-queries.md +194 -0
  282. package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/relations.md +308 -0
  283. package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/transactions.md +184 -0
  284. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/AGENTS.md +97 -0
  285. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/README.md +138 -0
  286. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/SKILL.md +116 -0
  287. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/assets/templates/_template.md +26 -0
  288. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/_sections.md +46 -0
  289. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-devtools-performance.md +69 -0
  290. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-formprovider-memo.md +78 -0
  291. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-testing-wrapper.md +63 -0
  292. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-complete-default-objects.md +66 -0
  293. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-separate-crud-operations.md +76 -0
  294. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-unique-fieldarray-per-name.md +58 -0
  295. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-use-field-id-as-key.md +54 -0
  296. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-virtualization-formprovider.md +64 -0
  297. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-avoid-double-registration.md +46 -0
  298. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-controller-field-props.md +56 -0
  299. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-local-state-combination.md +69 -0
  300. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-single-usecontroller-per-component.md +62 -0
  301. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-usecontroller-isolation.md +64 -0
  302. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-async-default-values.md +69 -0
  303. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-default-values.md +57 -0
  304. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-revalidate-mode.md +48 -0
  305. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-should-unregister.md +62 -0
  306. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-useeffect-dependency.md +54 -0
  307. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-validation-mode.md +51 -0
  308. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-avoid-isvalid-with-onsubmit.md +58 -0
  309. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-destructure-formstate.md +48 -0
  310. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-getfieldstate-for-single-field.md +49 -0
  311. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-subscribe-to-specific-fields.md +54 -0
  312. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-useformstate-isolation.md +62 -0
  313. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-mui-controller-pattern.md +59 -0
  314. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-form-import.md +64 -0
  315. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-select-wiring.md +64 -0
  316. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-value-transform.md +59 -0
  317. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-avoid-watch-in-render.md +48 -0
  318. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-deep-subscription.md +62 -0
  319. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-useformcontext-sparingly.md +58 -0
  320. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-default-value.md +50 -0
  321. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-over-watch.md +58 -0
  322. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-with-getvalues.md +54 -0
  323. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-watch-specific-fields.md +54 -0
  324. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-delay-error.md +52 -0
  325. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-dynamic-schema-factory.md +57 -0
  326. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-error-message-strategy.md +65 -0
  327. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-inline-vs-resolver.md +63 -0
  328. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-native-validation.md +60 -0
  329. package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-resolver-caching.md +58 -0
  330. package/templates/frontend/react-ssr/.cursor/skills/recharts/SKILL.md +713 -0
  331. package/templates/frontend/react-ssr/.cursor/skills/recharts/references/api_reference.md +1121 -0
  332. package/templates/frontend/react-ssr/.cursor/skills/recharts/references/best_practices.md +782 -0
  333. package/templates/frontend/react-ssr/.cursor/skills/recharts/references/examples.md +940 -0
  334. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/SKILL.md +114 -0
  335. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-gc-time.md +93 -0
  336. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-invalidation.md +116 -0
  337. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-placeholder-vs-initial.md +156 -0
  338. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-stale-time.md +80 -0
  339. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/err-error-boundaries.md +150 -0
  340. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/inf-page-params.md +132 -0
  341. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-invalidate-queries.md +118 -0
  342. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-mutation-state.md +169 -0
  343. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-optimistic-updates.md +137 -0
  344. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/network-mode.md +179 -0
  345. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/parallel-use-queries.md +152 -0
  346. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/perf-select-transform.md +144 -0
  347. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/persist-queries.md +194 -0
  348. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/pf-intent-prefetch.md +143 -0
  349. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-array-structure.md +50 -0
  350. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-factory-pattern.md +102 -0
  351. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-hierarchical-organization.md +76 -0
  352. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-include-dependencies.md +62 -0
  353. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-serializable.md +93 -0
  354. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/query-cancellation.md +171 -0
  355. package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/ssr-dehydration.md +158 -0
  356. package/templates/frontend/react-ssr/.cursor/skills/tanstack-table/SKILL.md +582 -0
  357. package/templates/frontend/react-ssr/.cursor/skills/zod-4/SKILL.md +216 -0
  358. package/templates/frontend/react-ssr/.dockerignore +14 -0
  359. package/templates/frontend/react-ssr/.env.example +9 -0
  360. package/templates/frontend/react-ssr/.husky/pre-commit +1 -0
  361. package/templates/frontend/react-ssr/Dockerfile +41 -0
  362. package/templates/frontend/react-ssr/README.md +121 -0
  363. package/templates/frontend/react-ssr/components.json +22 -0
  364. package/templates/frontend/react-ssr/docker-compose.yml +21 -0
  365. package/templates/frontend/react-ssr/eslint.config.mjs +26 -0
  366. package/templates/frontend/react-ssr/next.config.ts +7 -0
  367. package/templates/frontend/react-ssr/package.json +86 -0
  368. package/templates/frontend/react-ssr/postcss.config.mjs +5 -0
  369. package/templates/frontend/react-ssr/prisma/schema.prisma +75 -0
  370. package/templates/frontend/react-ssr/prisma/seed.ts +109 -0
  371. package/templates/frontend/react-ssr/prisma.config.ts +17 -0
  372. package/templates/frontend/react-ssr/skills-lock.json +65 -0
  373. package/templates/frontend/react-ssr/src/__tests__/components/ui/badge.test.tsx +26 -0
  374. package/templates/frontend/react-ssr/src/__tests__/components/ui/button.test.tsx +38 -0
  375. package/templates/frontend/react-ssr/src/__tests__/components/ui/card.test.tsx +39 -0
  376. package/templates/frontend/react-ssr/src/__tests__/components/ui/input.test.tsx +32 -0
  377. package/templates/frontend/react-ssr/src/__tests__/hooks/useLocalStorage.test.ts +53 -0
  378. package/templates/frontend/react-ssr/src/__tests__/lib/queryClient.test.ts +19 -0
  379. package/templates/frontend/react-ssr/src/__tests__/lib/utils.test.ts +24 -0
  380. package/templates/frontend/react-ssr/src/actions/auth.ts +91 -0
  381. package/templates/frontend/react-ssr/src/actions/contacto.ts +46 -0
  382. package/templates/frontend/react-ssr/src/actions/proyectos.ts +159 -0
  383. package/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/dashboard-client.tsx +321 -0
  384. package/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/page.tsx +48 -0
  385. package/templates/frontend/react-ssr/src/app/(authenticated)/layout.tsx +34 -0
  386. package/templates/frontend/react-ssr/src/app/(authenticated)/perfil/page.tsx +85 -0
  387. package/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/page.tsx +23 -0
  388. package/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/proyectos-crud-client.tsx +472 -0
  389. package/templates/frontend/react-ssr/src/app/(authenticated)/ui-components/page.tsx +358 -0
  390. package/templates/frontend/react-ssr/src/app/api/auth/[...nextauth]/route.ts +3 -0
  391. package/templates/frontend/react-ssr/src/app/auth/iniciar-sesion/page.tsx +148 -0
  392. package/templates/frontend/react-ssr/src/app/auth/recuperar-password/page.tsx +100 -0
  393. package/templates/frontend/react-ssr/src/app/auth/registro/page.tsx +154 -0
  394. package/templates/frontend/react-ssr/src/app/contacto/contacto-form.tsx +189 -0
  395. package/templates/frontend/react-ssr/src/app/contacto/page.tsx +11 -0
  396. package/templates/frontend/react-ssr/src/app/globals.css +99 -0
  397. package/templates/frontend/react-ssr/src/app/layout.tsx +22 -0
  398. package/templates/frontend/react-ssr/src/app/loading.tsx +7 -0
  399. package/templates/frontend/react-ssr/src/app/not-found.tsx +14 -0
  400. package/templates/frontend/react-ssr/src/app/page.tsx +331 -0
  401. package/templates/frontend/react-ssr/src/app/proyectos/page.tsx +178 -0
  402. package/templates/frontend/react-ssr/src/auth.ts +64 -0
  403. package/templates/frontend/react-ssr/src/components/layout/navbar.tsx +68 -0
  404. package/templates/frontend/react-ssr/src/components/layout/sidebar.tsx +109 -0
  405. package/templates/frontend/react-ssr/src/components/layout/sign-out-button.tsx +16 -0
  406. package/templates/frontend/react-ssr/src/components/providers.tsx +33 -0
  407. package/templates/frontend/react-ssr/src/components/ui/avatar.tsx +53 -0
  408. package/templates/frontend/react-ssr/src/components/ui/badge.tsx +42 -0
  409. package/templates/frontend/react-ssr/src/components/ui/breadcrumb.tsx +114 -0
  410. package/templates/frontend/react-ssr/src/components/ui/button.tsx +58 -0
  411. package/templates/frontend/react-ssr/src/components/ui/card.tsx +95 -0
  412. package/templates/frontend/react-ssr/src/components/ui/dialog.tsx +136 -0
  413. package/templates/frontend/react-ssr/src/components/ui/form.tsx +168 -0
  414. package/templates/frontend/react-ssr/src/components/ui/input.tsx +22 -0
  415. package/templates/frontend/react-ssr/src/components/ui/label.tsx +26 -0
  416. package/templates/frontend/react-ssr/src/components/ui/password-input.tsx +43 -0
  417. package/templates/frontend/react-ssr/src/components/ui/separator.tsx +30 -0
  418. package/templates/frontend/react-ssr/src/components/ui/table.tsx +240 -0
  419. package/templates/frontend/react-ssr/src/components/ui/tabs.tsx +76 -0
  420. package/templates/frontend/react-ssr/src/components/ui/textarea.tsx +21 -0
  421. package/templates/frontend/react-ssr/src/data/dashboard.ts +179 -0
  422. package/templates/frontend/react-ssr/src/hooks/useLocalStorage.ts +38 -0
  423. package/templates/frontend/react-ssr/src/lib/prisma.ts +24 -0
  424. package/templates/frontend/react-ssr/src/lib/queryClient.ts +25 -0
  425. package/templates/frontend/react-ssr/src/lib/utils.ts +6 -0
  426. package/templates/frontend/react-ssr/src/proxy.ts +31 -0
  427. package/templates/frontend/react-ssr/src/test/mocks/next-navigation.ts +16 -0
  428. package/templates/frontend/react-ssr/src/test/setup.ts +1 -0
  429. package/templates/frontend/react-ssr/src/test/utils.tsx +30 -0
  430. package/templates/frontend/react-ssr/src/types/index.ts +36 -0
  431. package/templates/frontend/react-ssr/tsconfig.json +41 -0
  432. package/templates/frontend/react-ssr/vitest.config.ts +41 -0
@@ -0,0 +1,1149 @@
1
+ ---
2
+ name: authjs-skills
3
+ description: Auth.js v5 setup for Next.js authentication including Google OAuth, credentials provider, environment configuration, and core API integration
4
+ ---
5
+
6
+ ## Links
7
+
8
+ - Getting Started: https://authjs.dev/getting-started/installation?framework=Next.js
9
+ - Migrating to v5: https://authjs.dev/getting-started/migrating-to-v5
10
+ - Google Provider: https://authjs.dev/getting-started/providers/google
11
+ - Credentials Provider: https://authjs.dev/getting-started/providers/credentials
12
+ - Core API Reference: https://authjs.dev/reference/core
13
+ - Session Management: https://authjs.dev/getting-started/session-management
14
+ - Concepts: https://authjs.dev/concepts
15
+
16
+ ## Installation
17
+
18
+ ```sh
19
+ pnpm add next-auth@beta
20
+ ```
21
+
22
+ **Note**: Auth.js v5 is currently in beta. Use `next-auth@beta` to install the latest v5 version.
23
+
24
+ ## What's New in Auth.js v5?
25
+
26
+ ### Key Changes from v4
27
+
28
+ - **Simplified Configuration**: More streamlined setup with better TypeScript support
29
+ - **Universal `auth()` Export**: Single function for authentication across all contexts
30
+ - **Enhanced Security**: Improved CSRF protection and session handling
31
+ - **Edge Runtime Support**: Full compatibility with Edge Runtime and middleware
32
+ - **Better Type Safety**: Improved TypeScript definitions throughout
33
+
34
+ ## Environment Variables
35
+
36
+ ### Required Environment Variables
37
+
38
+ ```env
39
+ # Auth.js Configuration
40
+ AUTH_SECRET=your_secret_key_here
41
+
42
+ # Google OAuth (if using Google provider)
43
+ AUTH_GOOGLE_ID=your_google_client_id
44
+ AUTH_GOOGLE_SECRET=your_google_client_secret
45
+
46
+ # For production deployments
47
+ AUTH_URL=https://yourdomain.com
48
+
49
+ # For development (optional, defaults to http://localhost:3000)
50
+ # AUTH_URL=http://localhost:3000
51
+ ```
52
+
53
+ ### Generating AUTH_SECRET
54
+
55
+ ```sh
56
+ # Generate a random secret (Unix/Linux/macOS)
57
+ openssl rand -base64 32
58
+
59
+ # Alternative using Node.js
60
+ node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
61
+
62
+ # Using pnpm
63
+ pnpm dlx auth secret
64
+ ```
65
+
66
+ **Important**: Never commit `AUTH_SECRET` to version control. Use `.env.local` for development.
67
+
68
+ ## Basic Setup (Next.js App Router)
69
+
70
+ ### 1. Create `auth.ts` Configuration File
71
+
72
+ Create `auth.ts` at the project root (next to `package.json`):
73
+
74
+ ```typescript
75
+ import NextAuth from "next-auth"
76
+ import Google from "next-auth/providers/google"
77
+ import Credentials from "next-auth/providers/credentials"
78
+
79
+ export const { handlers, signIn, signOut, auth } = NextAuth({
80
+ providers: [
81
+ Google({
82
+ clientId: process.env.AUTH_GOOGLE_ID,
83
+ clientSecret: process.env.AUTH_GOOGLE_SECRET,
84
+ }),
85
+ Credentials({
86
+ credentials: {
87
+ email: { label: "Email", type: "email" },
88
+ password: { label: "Password", type: "password" },
89
+ },
90
+ authorize: async (credentials) => {
91
+ // TODO: Implement your authentication logic here
92
+ // This is a basic example - see Credentials Provider section below for complete implementation
93
+ if (!credentials?.email || !credentials?.password) {
94
+ return null
95
+ }
96
+
97
+ // Example: validate against database (placeholder)
98
+ // See "Credentials Provider" section for full implementation with bcrypt
99
+ const user = { id: "1", email: credentials.email, name: "User" } // Replace with actual DB lookup
100
+
101
+ if (!user) {
102
+ return null
103
+ }
104
+
105
+ return {
106
+ id: user.id,
107
+ email: user.email,
108
+ name: user.name,
109
+ }
110
+ },
111
+ }),
112
+ ],
113
+ pages: {
114
+ signIn: '/auth/signin',
115
+ },
116
+ callbacks: {
117
+ authorized: async ({ auth }) => {
118
+ // Return true if user is authenticated
119
+ return !!auth
120
+ },
121
+ },
122
+ })
123
+ ```
124
+
125
+ **Note**: This is a basic setup example. For production-ready credentials authentication, see the "Credentials Provider" section below which includes proper password hashing with bcrypt and database integration.
126
+
127
+ ### 2. Create API Route Handler
128
+
129
+ Create `app/api/auth/[...nextauth]/route.ts`:
130
+
131
+ ```typescript
132
+ import { handlers } from "@/auth"
133
+
134
+ export const { GET, POST } = handlers
135
+ ```
136
+
137
+ ### 3. Add Middleware (Optional but Recommended)
138
+
139
+ Create `middleware.ts` at the project root:
140
+
141
+ ```typescript
142
+ export { auth as middleware } from "@/auth"
143
+
144
+ export const config = {
145
+ matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
146
+ }
147
+ ```
148
+
149
+ For more control:
150
+
151
+ ```typescript
152
+ import { auth } from "@/auth"
153
+
154
+ export default auth((req) => {
155
+ const isLoggedIn = !!req.auth
156
+ const isOnDashboard = req.nextUrl.pathname.startsWith('/dashboard')
157
+
158
+ if (isOnDashboard && !isLoggedIn) {
159
+ return Response.redirect(new URL('/auth/signin', req.url))
160
+ }
161
+ })
162
+
163
+ export const config = {
164
+ matcher: ['/dashboard/:path*', '/profile/:path*'],
165
+ }
166
+ ```
167
+
168
+ ## Google OAuth Provider
169
+
170
+ ### 1. Google Cloud Console Setup
171
+
172
+ 1. Go to [Google Cloud Console](https://console.cloud.google.com/)
173
+ 2. Create a new project or select existing
174
+ 3. Enable Google+ API
175
+ 4. Create OAuth 2.0 credentials:
176
+ - Application type: Web application
177
+ - Authorized redirect URIs:
178
+ - Development: `http://localhost:3000/api/auth/callback/google`
179
+ - Production: `https://yourdomain.com/api/auth/callback/google`
180
+ 5. Copy Client ID and Client Secret to `.env.local`
181
+
182
+ ### 2. Configuration
183
+
184
+ ```typescript
185
+ import NextAuth from "next-auth"
186
+ import Google from "next-auth/providers/google"
187
+
188
+ export const { handlers, signIn, signOut, auth } = NextAuth({
189
+ providers: [
190
+ Google({
191
+ clientId: process.env.AUTH_GOOGLE_ID,
192
+ clientSecret: process.env.AUTH_GOOGLE_SECRET,
193
+ authorization: {
194
+ params: {
195
+ prompt: "consent",
196
+ access_type: "offline",
197
+ response_type: "code"
198
+ }
199
+ }
200
+ }),
201
+ ],
202
+ })
203
+ ```
204
+
205
+ ### 3. Google Provider Options
206
+
207
+ ```typescript
208
+ Google({
209
+ clientId: process.env.AUTH_GOOGLE_ID,
210
+ clientSecret: process.env.AUTH_GOOGLE_SECRET,
211
+ // Request additional scopes
212
+ authorization: {
213
+ params: {
214
+ scope: "openid email profile",
215
+ prompt: "select_account", // Force account selection
216
+ }
217
+ },
218
+ // Allow specific domains only
219
+ allowDangerousEmailAccountLinking: false,
220
+ })
221
+ ```
222
+
223
+ ## Credentials Provider (Username/Password)
224
+
225
+ ### Required Dependencies
226
+
227
+ ```sh
228
+ # Install required packages for credentials provider
229
+ pnpm add bcryptjs zod
230
+ pnpm add -D @types/bcryptjs
231
+ ```
232
+
233
+ ### 1. Basic Configuration
234
+
235
+ ```typescript
236
+ import NextAuth from "next-auth"
237
+ import Credentials from "next-auth/providers/credentials"
238
+ import { z } from "zod"
239
+ import bcrypt from "bcryptjs"
240
+ import { prisma } from "@/lib/prisma"
241
+
242
+ const credentialsSchema = z.object({
243
+ email: z.string().email(),
244
+ password: z.string().min(8),
245
+ })
246
+
247
+ export const { handlers, signIn, signOut, auth } = NextAuth({
248
+ providers: [
249
+ Credentials({
250
+ credentials: {
251
+ email: { label: "Email", type: "email", placeholder: "user@example.com" },
252
+ password: { label: "Password", type: "password" },
253
+ },
254
+ authorize: async (credentials) => {
255
+ try {
256
+ const { email, password } = credentialsSchema.parse(credentials)
257
+
258
+ // Fetch user from database
259
+ const user = await prisma.user.findUnique({
260
+ where: { email },
261
+ })
262
+
263
+ if (!user) {
264
+ throw new Error("User not found")
265
+ }
266
+
267
+ // Verify password
268
+ const isValidPassword = await bcrypt.compare(password, user.hashedPassword)
269
+
270
+ if (!isValidPassword) {
271
+ throw new Error("Invalid password")
272
+ }
273
+
274
+ // Return user object (must include id)
275
+ return {
276
+ id: user.id,
277
+ email: user.email,
278
+ name: user.name,
279
+ image: user.image,
280
+ }
281
+ } catch (error) {
282
+ console.error("Authentication error:", error)
283
+ return null
284
+ }
285
+ },
286
+ }),
287
+ ],
288
+ session: {
289
+ strategy: "jwt", // Required for credentials provider
290
+ },
291
+ })
292
+ ```
293
+
294
+ ### 2. User Registration Example
295
+
296
+ ```typescript
297
+ // app/api/auth/register/route.ts
298
+ import { NextResponse } from "next/server"
299
+ import bcrypt from "bcryptjs"
300
+ import { z } from "zod"
301
+ import { prisma } from "@/lib/prisma"
302
+
303
+ const registerSchema = z.object({
304
+ email: z.string().email(),
305
+ password: z.string().min(8),
306
+ name: z.string().min(2),
307
+ })
308
+
309
+ export async function POST(req: Request) {
310
+ try {
311
+ const body = await req.json()
312
+ const { email, password, name } = registerSchema.parse(body)
313
+
314
+ // Check if user exists
315
+ const existingUser = await prisma.user.findUnique({
316
+ where: { email },
317
+ })
318
+
319
+ if (existingUser) {
320
+ return NextResponse.json(
321
+ { error: "User already exists" },
322
+ { status: 400 }
323
+ )
324
+ }
325
+
326
+ // Hash password
327
+ const hashedPassword = await bcrypt.hash(password, 10)
328
+
329
+ // Create user
330
+ const user = await prisma.user.create({
331
+ data: {
332
+ email,
333
+ name,
334
+ hashedPassword,
335
+ },
336
+ })
337
+
338
+ return NextResponse.json(
339
+ { message: "User created successfully", userId: user.id },
340
+ { status: 201 }
341
+ )
342
+ } catch (error) {
343
+ console.error("Registration error:", error)
344
+ return NextResponse.json(
345
+ { error: "Failed to register user" },
346
+ { status: 500 }
347
+ )
348
+ }
349
+ }
350
+ ```
351
+
352
+ ## Using Auth in Components
353
+
354
+ ### Server Components
355
+
356
+ ```typescript
357
+ import { auth } from "@/auth"
358
+
359
+ export default async function ProfilePage() {
360
+ const session = await auth()
361
+
362
+ if (!session?.user) {
363
+ return <div>Not authenticated</div>
364
+ }
365
+
366
+ return (
367
+ <div>
368
+ <h1>Welcome, {session.user.name}!</h1>
369
+ <p>Email: {session.user.email}</p>
370
+ </div>
371
+ )
372
+ }
373
+ ```
374
+
375
+ ### Server Actions
376
+
377
+ ```typescript
378
+ "use server"
379
+
380
+ import { auth } from "@/auth"
381
+ import { revalidatePath } from "next/cache"
382
+ import { prisma } from "@/lib/prisma"
383
+
384
+ export async function updateProfile(formData: FormData) {
385
+ const session = await auth()
386
+
387
+ if (!session?.user) {
388
+ throw new Error("Not authenticated")
389
+ }
390
+
391
+ const name = formData.get("name") as string
392
+
393
+ // Update database
394
+ await prisma.user.update({
395
+ where: { id: session.user.id },
396
+ data: { name },
397
+ })
398
+
399
+ revalidatePath("/profile")
400
+ }
401
+ ```
402
+
403
+ ### Client Components (with SessionProvider)
404
+
405
+ ```typescript
406
+ // app/providers.tsx
407
+ "use client"
408
+
409
+ import { SessionProvider } from "next-auth/react"
410
+
411
+ export function Providers({ children }: { children: React.ReactNode }) {
412
+ return <SessionProvider>{children}</SessionProvider>
413
+ }
414
+ ```
415
+
416
+ ```typescript
417
+ // app/layout.tsx
418
+ import { Providers } from "./providers"
419
+
420
+ export default function RootLayout({
421
+ children,
422
+ }: {
423
+ children: React.ReactNode
424
+ }) {
425
+ return (
426
+ <html lang="en">
427
+ <body>
428
+ <Providers>{children}</Providers>
429
+ </body>
430
+ </html>
431
+ )
432
+ }
433
+ ```
434
+
435
+ ```typescript
436
+ // app/components/user-profile.tsx
437
+ "use client"
438
+
439
+ import { useSession, signIn, signOut } from "next-auth/react"
440
+
441
+ export function UserProfile() {
442
+ const { data: session, status } = useSession()
443
+
444
+ if (status === "loading") {
445
+ return <div>Loading...</div>
446
+ }
447
+
448
+ if (!session) {
449
+ return (
450
+ <button onClick={() => signIn()}>
451
+ Sign In
452
+ </button>
453
+ )
454
+ }
455
+
456
+ return (
457
+ <div>
458
+ <p>Signed in as {session.user?.email}</p>
459
+ <button onClick={() => signOut()}>
460
+ Sign Out
461
+ </button>
462
+ </div>
463
+ )
464
+ }
465
+ ```
466
+
467
+ ## Sign In/Out Actions
468
+
469
+ ### Programmatic Sign In
470
+
471
+ ```typescript
472
+ import { signIn } from "@/auth"
473
+
474
+ // Server Action
475
+ export async function handleSignIn(provider: string) {
476
+ "use server"
477
+ await signIn(provider)
478
+ }
479
+
480
+ // With credentials
481
+ export async function handleCredentialsSignIn(formData: FormData) {
482
+ "use server"
483
+ await signIn("credentials", formData)
484
+ }
485
+
486
+ // With redirect
487
+ export async function handleGoogleSignIn() {
488
+ "use server"
489
+ await signIn("google", { redirectTo: "/dashboard" })
490
+ }
491
+ ```
492
+
493
+ ### Sign In Form Component
494
+
495
+ ```typescript
496
+ // app/auth/signin/page.tsx
497
+ import { signIn } from "@/auth"
498
+
499
+ export default function SignInPage() {
500
+ return (
501
+ <div>
502
+ <h1>Sign In</h1>
503
+
504
+ {/* Google OAuth */}
505
+ <form
506
+ action={async () => {
507
+ "use server"
508
+ await signIn("google")
509
+ }}
510
+ >
511
+ <button type="submit">Sign in with Google</button>
512
+ </form>
513
+
514
+ {/* Credentials */}
515
+ <form
516
+ action={async (formData) => {
517
+ "use server"
518
+ await signIn("credentials", formData)
519
+ }}
520
+ >
521
+ <input name="email" type="email" placeholder="Email" required />
522
+ <input name="password" type="password" placeholder="Password" required />
523
+ <button type="submit">Sign In</button>
524
+ </form>
525
+ </div>
526
+ )
527
+ }
528
+ ```
529
+
530
+ ### Sign Out
531
+
532
+ ```typescript
533
+ import { signOut } from "@/auth"
534
+
535
+ export default function SignOutButton() {
536
+ return (
537
+ <form
538
+ action={async () => {
539
+ "use server"
540
+ await signOut()
541
+ }}
542
+ >
543
+ <button type="submit">Sign Out</button>
544
+ </form>
545
+ )
546
+ }
547
+ ```
548
+
549
+ ## Session Management
550
+
551
+ ### Session Strategy
552
+
553
+ Auth.js v5 supports two session strategies:
554
+
555
+ 1. **JWT (Default)**: Stores session in encrypted JWT token
556
+ 2. **Database**: Stores session in database
557
+
558
+ ```typescript
559
+ export const { handlers, signIn, signOut, auth } = NextAuth({
560
+ session: {
561
+ strategy: "jwt", // or "database"
562
+ maxAge: 30 * 24 * 60 * 60, // 30 days
563
+ updateAge: 24 * 60 * 60, // 24 hours
564
+ },
565
+ })
566
+ ```
567
+
568
+ ### Extending the Session
569
+
570
+ ```typescript
571
+ import NextAuth from "next-auth"
572
+ import type { DefaultSession } from "next-auth"
573
+
574
+ declare module "next-auth" {
575
+ interface Session {
576
+ user: {
577
+ id: string
578
+ role: string
579
+ } & DefaultSession["user"]
580
+ }
581
+ }
582
+
583
+ export const { handlers, signIn, signOut, auth } = NextAuth({
584
+ callbacks: {
585
+ jwt({ token, user }) {
586
+ if (user) {
587
+ token.id = user.id
588
+ token.role = user.role
589
+ }
590
+ return token
591
+ },
592
+ session({ session, token }) {
593
+ if (session.user) {
594
+ session.user.id = token.id as string
595
+ session.user.role = token.role as string
596
+ }
597
+ return session
598
+ },
599
+ },
600
+ })
601
+ ```
602
+
603
+ ## Callbacks
604
+
605
+ ### Essential Callbacks
606
+
607
+ ```typescript
608
+ export const { handlers, signIn, signOut, auth } = NextAuth({
609
+ callbacks: {
610
+ // Called when user signs in
611
+ async signIn({ user, account, profile }) {
612
+ // Return true to allow sign in, false to deny
613
+ // Example: Check if email is verified
614
+ if (account?.provider === "google") {
615
+ return profile?.email_verified === true
616
+ }
617
+ return true
618
+ },
619
+
620
+ // Called whenever a JWT is created or updated
621
+ async jwt({ token, user, account }) {
622
+ if (user) {
623
+ token.id = user.id
624
+ }
625
+ if (account) {
626
+ token.accessToken = account.access_token
627
+ }
628
+ return token
629
+ },
630
+
631
+ // Called whenever a session is checked
632
+ async session({ session, token }) {
633
+ session.user.id = token.id as string
634
+ session.accessToken = token.accessToken as string
635
+ return session
636
+ },
637
+
638
+ // Called on middleware and server-side auth checks
639
+ async authorized({ auth, request }) {
640
+ const isLoggedIn = !!auth?.user
641
+ const isOnDashboard = request.nextUrl.pathname.startsWith("/dashboard")
642
+
643
+ if (isOnDashboard) {
644
+ return isLoggedIn
645
+ }
646
+
647
+ return true
648
+ },
649
+
650
+ // Called when user is redirected
651
+ async redirect({ url, baseUrl }) {
652
+ // Allows relative callback URLs
653
+ if (url.startsWith("/")) return `${baseUrl}${url}`
654
+ // Allows callback URLs on the same origin
655
+ else if (new URL(url).origin === baseUrl) return url
656
+ return baseUrl
657
+ },
658
+ },
659
+ })
660
+ ```
661
+
662
+ ## Database Adapter (Optional)
663
+
664
+ For persisting users, accounts, and sessions in a database, install the Prisma adapter:
665
+
666
+ ```sh
667
+ pnpm add @auth/prisma-adapter
668
+ ```
669
+
670
+ Then configure it in your `auth.ts`:
671
+
672
+ ```typescript
673
+ import NextAuth from "next-auth"
674
+ import { PrismaAdapter } from "@auth/prisma-adapter"
675
+ import { prisma } from "@/lib/prisma"
676
+
677
+ export const { handlers, signIn, signOut, auth } = NextAuth({
678
+ adapter: PrismaAdapter(prisma),
679
+ session: {
680
+ strategy: "database",
681
+ },
682
+ providers: [
683
+ // ... providers
684
+ ],
685
+ })
686
+ ```
687
+
688
+ Required Prisma schema:
689
+
690
+ ```prisma
691
+ model User {
692
+ id String @id @default(cuid())
693
+ name String?
694
+ email String @unique
695
+ emailVerified DateTime?
696
+ image String?
697
+ accounts Account[]
698
+ sessions Session[]
699
+ }
700
+
701
+ model Account {
702
+ id String @id @default(cuid())
703
+ userId String
704
+ type String
705
+ provider String
706
+ providerAccountId String
707
+ refresh_token String?
708
+ access_token String?
709
+ expires_at Int?
710
+ token_type String?
711
+ scope String?
712
+ id_token String?
713
+ session_state String?
714
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
715
+
716
+ @@unique([provider, providerAccountId])
717
+ }
718
+
719
+ model Session {
720
+ id String @id @default(cuid())
721
+ sessionToken String @unique
722
+ userId String
723
+ expires DateTime
724
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
725
+ }
726
+ ```
727
+
728
+ ## API Routes
729
+
730
+ ### Custom API Endpoints
731
+
732
+ ```typescript
733
+ // app/api/user/route.ts
734
+ import { auth } from "@/auth"
735
+ import { NextResponse } from "next/server"
736
+
737
+ export async function GET() {
738
+ const session = await auth()
739
+
740
+ if (!session?.user) {
741
+ return NextResponse.json(
742
+ { error: "Unauthorized" },
743
+ { status: 401 }
744
+ )
745
+ }
746
+
747
+ return NextResponse.json({
748
+ user: session.user,
749
+ })
750
+ }
751
+ ```
752
+
753
+ ### Protected Route Helper
754
+
755
+ ```typescript
756
+ // lib/auth-helpers.ts
757
+ import { auth } from "@/auth"
758
+ import { NextResponse } from "next/server"
759
+ import type { Session } from "next-auth"
760
+
761
+ export async function withAuth(
762
+ handler: (session: Session) => Promise<NextResponse>
763
+ ) {
764
+ const session = await auth()
765
+
766
+ if (!session?.user) {
767
+ return NextResponse.json(
768
+ { error: "Unauthorized" },
769
+ { status: 401 }
770
+ )
771
+ }
772
+
773
+ return handler(session)
774
+ }
775
+
776
+ // Usage
777
+ export async function GET() {
778
+ return withAuth(async (session) => {
779
+ return NextResponse.json({ userId: session.user.id })
780
+ })
781
+ }
782
+ ```
783
+
784
+ ## Best Practices
785
+
786
+ ### Security
787
+
788
+ - **Always hash passwords**: Use bcrypt, argon2, or similar
789
+ - **Use HTTPS in production**: Required for secure cookie transmission
790
+ - **Validate environment variables**: Check AUTH_SECRET and provider credentials
791
+ - **Set secure cookie options**:
792
+ ```typescript
793
+ cookies: {
794
+ sessionToken: {
795
+ name: `__Secure-next-auth.session-token`,
796
+ options: {
797
+ httpOnly: true,
798
+ sameSite: 'lax',
799
+ path: '/',
800
+ secure: process.env.NODE_ENV === 'production',
801
+ },
802
+ },
803
+ }
804
+ ```
805
+ - **Implement rate limiting**: Protect sign-in endpoints
806
+ - **Use CSRF protection**: Enabled by default in v5
807
+ - **Validate redirects**: Use the `redirect` callback to prevent open redirects
808
+
809
+ ### Session Management
810
+
811
+ - **Use appropriate maxAge**: Default 30 days, adjust based on security requirements
812
+ - **Update sessions regularly**: Use `updateAge` to refresh session data
813
+ - **Handle session expiry gracefully**: Provide clear UI feedback
814
+ - **Secure session storage**: Use database strategy for sensitive applications
815
+
816
+ ### Provider Configuration
817
+
818
+ - **Google OAuth**: Request minimum required scopes
819
+ - **Credentials**: Always validate input with zod or similar
820
+ - **Multiple providers**: Allow account linking carefully
821
+ - **Provider-specific logic**: Use callbacks to handle provider differences
822
+
823
+ ### Performance
824
+
825
+ - **Cache session checks**: Use middleware for route protection
826
+ - **Minimize database calls**: Use JWT strategy when appropriate
827
+ - **Optimize database queries**: Add indexes on frequently queried fields
828
+ - **Use Edge Runtime**: For faster authentication checks in middleware
829
+
830
+ ### Type Safety
831
+
832
+ - **Extend types properly**: Use module augmentation for custom session fields
833
+ - **Validate inputs**: Use zod for runtime type checking
834
+ - **TypeScript strict mode**: Enable for better type safety
835
+
836
+ ## Common Patterns
837
+
838
+ ### Protected Pages with Middleware
839
+
840
+ ```typescript
841
+ import { auth } from "@/auth"
842
+ import { NextResponse } from "next/server"
843
+
844
+ export default auth((req) => {
845
+ const isLoggedIn = !!req.auth
846
+ const { pathname } = req.nextUrl
847
+
848
+ // Public routes
849
+ const publicRoutes = ['/auth/signin', '/auth/register', '/']
850
+ if (publicRoutes.includes(pathname)) {
851
+ return NextResponse.next()
852
+ }
853
+
854
+ // Protected routes
855
+ if (!isLoggedIn) {
856
+ const signInUrl = new URL('/auth/signin', req.url)
857
+ signInUrl.searchParams.set('callbackUrl', pathname)
858
+ return NextResponse.redirect(signInUrl)
859
+ }
860
+
861
+ // Role-based access
862
+ const adminRoutes = ['/admin']
863
+ if (adminRoutes.some(route => pathname.startsWith(route))) {
864
+ if (req.auth.user.role !== 'admin') {
865
+ return NextResponse.redirect(new URL('/unauthorized', req.url))
866
+ }
867
+ }
868
+
869
+ return NextResponse.next()
870
+ })
871
+
872
+ export const config = {
873
+ matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
874
+ }
875
+ ```
876
+
877
+ ### Multi-Provider Setup
878
+
879
+ ```typescript
880
+ import NextAuth from "next-auth"
881
+ import Google from "next-auth/providers/google"
882
+ import GitHub from "next-auth/providers/github"
883
+ import Credentials from "next-auth/providers/credentials"
884
+ import { prisma } from "@/lib/prisma"
885
+
886
+ export const { handlers, signIn, signOut, auth } = NextAuth({
887
+ providers: [
888
+ Google({
889
+ clientId: process.env.AUTH_GOOGLE_ID,
890
+ clientSecret: process.env.AUTH_GOOGLE_SECRET,
891
+ }),
892
+ GitHub({
893
+ clientId: process.env.AUTH_GITHUB_ID,
894
+ clientSecret: process.env.AUTH_GITHUB_SECRET,
895
+ }),
896
+ Credentials({
897
+ // ... credentials config
898
+ }),
899
+ ],
900
+ callbacks: {
901
+ async signIn({ user, account, profile }) {
902
+ // Link accounts with same email
903
+ if (account?.provider !== "credentials") {
904
+ const existingUser = await prisma.user.findUnique({
905
+ where: { email: user.email },
906
+ })
907
+
908
+ if (existingUser) {
909
+ // Link account to existing user
910
+ await prisma.account.create({
911
+ data: {
912
+ userId: existingUser.id,
913
+ type: account.type,
914
+ provider: account.provider,
915
+ providerAccountId: account.providerAccountId,
916
+ access_token: account.access_token,
917
+ refresh_token: account.refresh_token,
918
+ },
919
+ })
920
+ }
921
+ }
922
+ return true
923
+ },
924
+ },
925
+ })
926
+ ```
927
+
928
+ ### Custom Sign In Page
929
+
930
+ ```typescript
931
+ // app/auth/signin/page.tsx
932
+ import { signIn } from "@/auth"
933
+ import { redirect } from "next/navigation"
934
+
935
+ export default function SignInPage({
936
+ searchParams,
937
+ }: {
938
+ searchParams: { callbackUrl?: string }
939
+ }) {
940
+ const callbackUrl = searchParams.callbackUrl || "/dashboard"
941
+
942
+ return (
943
+ <div className="flex min-h-screen items-center justify-center">
944
+ <div className="w-full max-w-md space-y-8 p-8">
945
+ <h1 className="text-2xl font-bold text-center">Sign In</h1>
946
+
947
+ {/* OAuth Providers */}
948
+ <div className="space-y-4">
949
+ <form
950
+ action={async () => {
951
+ "use server"
952
+ await signIn("google", { redirectTo: callbackUrl })
953
+ }}
954
+ >
955
+ <button
956
+ type="submit"
957
+ className="w-full bg-white border border-gray-300 text-gray-700 py-2 px-4 rounded hover:bg-gray-50"
958
+ >
959
+ Continue with Google
960
+ </button>
961
+ </form>
962
+ </div>
963
+
964
+ <div className="relative">
965
+ <div className="absolute inset-0 flex items-center">
966
+ <div className="w-full border-t border-gray-300" />
967
+ </div>
968
+ <div className="relative flex justify-center text-sm">
969
+ <span className="bg-white px-2 text-gray-500">Or</span>
970
+ </div>
971
+ </div>
972
+
973
+ {/* Credentials Form */}
974
+ <form
975
+ action={async (formData) => {
976
+ "use server"
977
+ try {
978
+ await signIn("credentials", {
979
+ email: formData.get("email"),
980
+ password: formData.get("password"),
981
+ redirectTo: callbackUrl,
982
+ })
983
+ } catch (error) {
984
+ redirect(`/auth/signin?error=CredentialsSignin&callbackUrl=${callbackUrl}`)
985
+ }
986
+ }}
987
+ className="space-y-4"
988
+ >
989
+ <div>
990
+ <label htmlFor="email" className="block text-sm font-medium text-gray-700">
991
+ Email
992
+ </label>
993
+ <input
994
+ id="email"
995
+ name="email"
996
+ type="email"
997
+ required
998
+ className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md"
999
+ />
1000
+ </div>
1001
+ <div>
1002
+ <label htmlFor="password" className="block text-sm font-medium text-gray-700">
1003
+ Password
1004
+ </label>
1005
+ <input
1006
+ id="password"
1007
+ name="password"
1008
+ type="password"
1009
+ required
1010
+ className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md"
1011
+ />
1012
+ </div>
1013
+ <button
1014
+ type="submit"
1015
+ className="w-full bg-blue-600 text-white py-2 px-4 rounded hover:bg-blue-700"
1016
+ >
1017
+ Sign In
1018
+ </button>
1019
+ </form>
1020
+ </div>
1021
+ </div>
1022
+ )
1023
+ }
1024
+ ```
1025
+
1026
+ ### Role-Based Access Control (RBAC)
1027
+
1028
+ ```typescript
1029
+ // lib/auth-rbac.ts
1030
+ import { auth } from "@/auth"
1031
+
1032
+ export type Role = "admin" | "user" | "guest"
1033
+
1034
+ export async function checkRole(allowedRoles: Role[]) {
1035
+ const session = await auth()
1036
+
1037
+ if (!session?.user) {
1038
+ return false
1039
+ }
1040
+
1041
+ const userRole = session.user.role as Role
1042
+ return allowedRoles.includes(userRole)
1043
+ }
1044
+
1045
+ // Usage in Server Component
1046
+ export default async function AdminPage() {
1047
+ const hasAccess = await checkRole(["admin"])
1048
+
1049
+ if (!hasAccess) {
1050
+ redirect("/unauthorized")
1051
+ }
1052
+
1053
+ return <div>Admin Dashboard</div>
1054
+ }
1055
+
1056
+ // Usage in Server Action
1057
+ export async function deleteUser(userId: string) {
1058
+ "use server"
1059
+
1060
+ const hasAccess = await checkRole(["admin"])
1061
+
1062
+ if (!hasAccess) {
1063
+ throw new Error("Unauthorized")
1064
+ }
1065
+
1066
+ const { prisma } = await import("@/lib/prisma")
1067
+ await prisma.user.delete({ where: { id: userId } })
1068
+ }
1069
+ ```
1070
+
1071
+ ## Migration from v4 to v5
1072
+
1073
+ ### Key Differences
1074
+
1075
+ 1. **Import changes**: `next-auth` package remains the same, but imports are simplified
1076
+ 2. **Universal `auth()`**: Replace `getServerSession` with `auth()`
1077
+ 3. **Middleware**: Use `auth` as middleware directly
1078
+ 4. **Configuration**: More streamlined, fewer options needed
1079
+
1080
+ ### Migration Steps
1081
+
1082
+ ```typescript
1083
+ // v4 (old)
1084
+ import { getServerSession } from "next-auth/next"
1085
+ import { authOptions } from "@/lib/auth"
1086
+
1087
+ export async function GET() {
1088
+ const session = await getServerSession(authOptions)
1089
+ }
1090
+
1091
+ // v5 (new)
1092
+ import { auth } from "@/auth"
1093
+
1094
+ export async function GET() {
1095
+ const session = await auth()
1096
+ }
1097
+ ```
1098
+
1099
+ ```typescript
1100
+ // v4 middleware (old)
1101
+ import { withAuth } from "next-auth/middleware"
1102
+
1103
+ export default withAuth({
1104
+ callbacks: {
1105
+ authorized: ({ token }) => !!token,
1106
+ },
1107
+ })
1108
+
1109
+ // v5 middleware (new)
1110
+ export { auth as middleware } from "@/auth"
1111
+ ```
1112
+
1113
+ ## Troubleshooting
1114
+
1115
+ ### Common Issues
1116
+
1117
+ **AUTH_SECRET not set**:
1118
+ ```
1119
+ Error: AUTH_SECRET environment variable is not set
1120
+ ```
1121
+ Generate and set `AUTH_SECRET` in `.env.local`
1122
+
1123
+ **Google OAuth redirect mismatch**:
1124
+ ```
1125
+ Error: redirect_uri_mismatch
1126
+ ```
1127
+ Ensure redirect URI in Google Console matches: `http://localhost:3000/api/auth/callback/google`
1128
+
1129
+ **Session not persisting**:
1130
+ - Check `AUTH_URL` is set correctly
1131
+ - Verify cookies are not blocked
1132
+ - Ensure `sessionToken` cookie is being set (check browser DevTools)
1133
+
1134
+ **TypeScript errors with session**:
1135
+ - Extend the `Session` and `JWT` types using module augmentation
1136
+ - Run `pnpm tsc --noEmit` to check for type errors
1137
+
1138
+ **Credentials provider not working**:
1139
+ - Ensure `session.strategy` is set to `"jwt"`
1140
+ - Check `authorize` function returns correct user object with `id` field
1141
+ - Verify password hashing/comparison logic
1142
+
1143
+ ## Resources
1144
+
1145
+ - **Official Docs**: https://authjs.dev
1146
+ - **GitHub**: https://github.com/nextauthjs/next-auth
1147
+ - **Discord Community**: https://discord.gg/nextauth
1148
+ - **Examples**: https://github.com/nextauthjs/next-auth/tree/main/apps/examples
1149
+ - **Provider List**: https://authjs.dev/getting-started/providers