An example of using Next Auth
with ioredis
library to save user data into Redis Server with IORedisAdapter.
IORedisAdapter
saves data with Hash
data structure instead of JSON.stringify
to simplify the management of user data.
For example, a role
field ("admin" | "moderator" | "user"
) in User object in [...nextauth].ts
-
Create an
.env
file work the following content:REDIS_URL="redis://....." GITHUB_CLIENT_ID = "" GITHUB_CLIENT_SECRET = "" NEXTAUTH_URL="http://localhost:3000" NEXTAUTH_SECRET="SOME_SECRET"
-
Run the server
npm run dev # or yarn dev