Next.js で SNS アカウント認証!
# はじめに前回、Next.js について調べてみたので、今回はよく使うアカウント認証について、アプリケーションを作ってみようと思います。Next.js を開発している Vercel が作っている NextAuth.js を使用します。# アプリを作ってみるsample という名前でアカウント認証付きのアプリケーションを作成します。## 1. まずは、Hello world!```$ yarn create next-app --typescript$ cd sample$ yarn add next-auth$ yarn add -D [at]types/next-auth$ yarn dev```## 2. いらないファイルを削除以下のファイルを削除します。- sample/pages/api/hello.ts- sample/styles/Home.module.css## 3. API route を追加`pages/api/auth/[...nextauth].ts` を作成します。```import NextAuth from 'next-auth'import Providers from 'next-auth/providers'export default NextAuth({ providers: [ Providers.GitHub({ clientId: process.env.GITHUB_ID, clientSecret: process.env.GITHUB_SECRET
0