Realtime chat using GraphQL Live Queries, Next.js and NextAuth.js — tutorial
- NextAuth.js
- Next.js
- Apollo Client
- Grafbase
- Server-Sent Events
- GraphQL Live Queries
- GraphQL
- Tailwind CSS
npm install
- Create a GitHub OAuth App with your app details for development purposes. Make sure to set
Authorization callback URL
tohttp://localhost:3000/api/auth/callback/github
cp .env.example .env
and add values forGITHUB_CLIENT_ID
andGITHUB_CLIENT_SECRET
from step 2.- Generate a secret value for
NEXTAUTH_SECRET
and add it to.env
cp grafbase/.env.example grafbase/.env
- Add the same
NEXTAUTH_SECRET
tografbase/.env
npx grafbase dev
npm run dev
- Fork and Push this repo to GitHub
- Create an account with Grafbase
- Create new project with Grafbase and connect your forked repo
- Add environment variable
NEXTAUTH_SECRET
during project creation - Create a GitHub OAuth App with your app details for production purposes. Make sure to set
Authorization callback URL
to[YOUR_DESIRED_VERCEL_DOMAIN]/api/auth/callback/github
- Deploy to Vercel and add
.env
values (NEXT_PUBLIC_GRAFBASE_API_URL
*,NEXTAUTH_SECRET
,GITHUB_CLIENT_ID
,GITHUB_CLIENT_SECRET
)
* NEXT_PUBLIC_GRAFBASE_URL
is your production API endpoint. You can find this from the Connect modal in your project dashboard.