{"id":2662,"date":"2023-07-29T15:58:24","date_gmt":"2023-07-29T06:58:24","guid":{"rendered":"https:\/\/www.agile-software.site\/?p=2662"},"modified":"2024-12-14T22:29:32","modified_gmt":"2024-12-14T13:29:32","slug":"next-js%e3%81%a8prisma%e3%81%a7%e6%a7%8b%e7%af%89%e3%81%99%e3%82%8b%e8%aa%8d%e8%a8%bc%e3%82%b7%e3%82%b9%e3%83%86%e3%83%a0","status":"publish","type":"post","link":"https:\/\/agile-software.net\/?p=2662","title":{"rendered":"Next.js\u3068Prisma\u3067\u69cb\u7bc9\u3059\u308b\u8a8d\u8a3c\u30b7\u30b9\u30c6\u30e0"},"content":{"rendered":"\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>npx create-next-app@latest .\n&#x2714; Would you like to use TypeScript? \u2026 Yes\n&#x2714; Would you like to use ESLint? \u2026 Yes\n&#x2714; Would you like to use Tailwind CSS? \u2026 Yes\n&#x2714; Would you like to use `src\/` directory? \u2026 No\n&#x2714; Would you like to use App Router? (recommended) \u2026 Yes\n&#x2714; Would you like to customize the default import alias? \u2026 No<\/code><\/pre><\/div>\n\n\n\n<p>NextAuth\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u3057\u3066\u30a2\u30c0\u30d7\u30bf\u30fc\uff08\u4eca\u56de\u306f Prisma \uff09\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308aNextAuth.js\u3068Prisma\u3092\u9023\u643a\u3057\u3066\u3001\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u3042\u3063\u305f\u969b\u306bPrisma\u7d4c\u7531\u3067\u30e6\u30fc\u30b6\u30fc\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-jin-gb-block-icon-box jin-icon-caution jin-iconbox\"><div class=\"jin-iconbox-icons\"><i class=\"jic jin-ifont-caution jin-icons\"><\/i><\/div><div class=\"jin-iconbox-main\">\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">bcrypt<\/mark><\/strong>\u3068\u306f\u3001Blowfish\u6697\u53f7\u3092\u57fa\u76e4\u3068\u3057\u305f\u30d1\u30b9\u30ef\u30fc\u30c9\u30cf\u30c3\u30b7\u30e5\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3067\u3059\u3002<br>\u4e00\u822c\u7684\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u306f\u3001<strong>\u5143\u306b\u623b\u3059\u3053\u3068\u304c\u56f0\u96e3\u3067\u3042\u308b\u300c\u4e00\u65b9\u5411\u6027\u95a2\u6570\u300d<\/strong>\u306e\u6027\u8cea\u3092\u6301\u3064\u30cf\u30c3\u30b7\u30e5\u95a2\u6570\u3092\u7528\u3044\u3066\u30cf\u30c3\u30b7\u30e5\u5024\u3067\u4fdd\u7ba1\u3057\u307e\u3059\u3002<\/p>\n<\/div><\/div>\n\n\n\n<p>\u300c\u5e73\u6587\u300d\u306f\u6f0f\u6d29\u3057\u305f\u3089\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u76d7\u307e\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u300c\u6697\u53f7\u6587\u300d\u306f\u6697\u53f7\u5316\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u300c\u6697\u53f7\u6587\u300d\u3092\u5fa9\u53f7\u3059\u308b\u300c\u9375\u300d\u304c\u3042\u308c\u3070\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u89e3\u8aad\u3067\u304d\u307e\u3059\u3002\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u60c5\u5831\u6f0f\u6d29\u3057\u305f\u6642\u70b9\u3067\u3001\u3082\u3057\u304b\u3057\u305f\u3089\u300c\u9375\u300d\u3082\u6f0f\u6d29\u3057\u3066\u3044\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u305d\u306e\u305f\u3081\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u6697\u53f7\u6587\u3067\u4fdd\u7ba1\u3059\u308b\u306e\u306f\u5341\u5206\u306a\u5bfe\u7b56\u3068\u306f\u3044\u3048\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u305d\u3057\u3066\u6700\u5f8c\u306f\u300c\u30cf\u30c3\u30b7\u30e5\u5024\u300d\u3067\u3059\u3002\u9069\u5207\u306a\u30cf\u30c3\u30b7\u30e5\u95a2\u6570\u3092\u4f7f\u3063\u3066\u3044\u308c\u3070\u30cf\u30c3\u30b7\u30e5\u5024\u3078\u3068\u5909\u63db\u3057\u305f\u5024\u3092\u5143\u306b\u623b\u3059\u3053\u3068\u306f\u975e\u5e38\u306b\u56f0\u96e3\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>npm i @hookform\/resolvers @next-auth\/prisma-adapter @prisma\/client axios bcrypt date-fns encoding next-auth next-cloudinary react-hook-form react-hot-toast react-icons zod zustand<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>npm i --save-dev @types\/bcrypt prisma<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>Server [localhost]:\nDatabase [postgres]:\nPort [5432]:\nUsername [postgres]:\nClient Encoding [SJIS]:\n\u30e6\u30fc\u30b6\u30fc postgres \u306e\u30d1\u30b9\u30ef\u30fc\u30c9:\npsql (15.3)\n&quot;help&quot;\u3067\u30d8\u30eb\u30d7\u3092\u8868\u793a\u3057\u307e\u3059\u3002\n\npostgres=# create database nextjs_prisma;\nCREATE DATABASE<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>npx prisma init --datasource-provider postgresql<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u30e2\u30c7\u30eb\u4f5c\u6210<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>model User {\n  id             String    @id @default(uuid())\n  name           String?\n  email          String?   @unique\n  emailVerified  DateTime?\n  image          String?\n  hashedPassword String?\n  createdAt      DateTime  @default(now())\n  updatedAt      DateTime  @updatedAt\n  accounts       Account[]\n}<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>NextAuth\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u3057\u3066\u30a2\u30c0\u30d7\u30bf\u30fc\uff08\u4eca\u56de\u306f Prisma \uff09\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308aNextAuth.js\u3068Prisma\u3092\u9023\u643a\u3057\u3066\u3001\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u3042\u3063\u305f\u969b\u306bPrisma\u7d4c\u7531\u3067\u30e6\u30fc\u30b6\u30fc\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3057\u3066\u3044\u307e\u3059<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jin_ogp_image_url":"","_jin_last_featured_id":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2662","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/2662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2662"}],"version-history":[{"count":3,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/2662\/revisions"}],"predecessor-version":[{"id":2929,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/2662\/revisions\/2929"}],"wp:attachment":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}