/strapi-nextauth-template

Implementation of a local authentication system with using Strapi Next.js Framework and NextAuth

Primary LanguageJavaScript

Strapi authentication with Next.js and NextAuth.js

Index page

About

Implementation of a local authentication system with using Strapi Next.js Framework and NextAuth.

Table of contents

Requirements

  • Node.js >= 10.x installed on your machine
  • NPM >= 6.x or YARN installed on your machine
  • PostgreSQL installed on your machine

Installation

Install the dependencies of the 2 apps "app, api".

cd /app
yarn install

cd /api
yarn install

Now, we will proceed to create a database with postgresql

sudo -i -u postgres

Once inside our postgres user we run the command

psql

In order to enter the postgresql bash and create our database as follows

CREATE DATABASE strapi;
CREATE ROLE strapiu WITH LOGIN PASSWORD 'strongpassword';
GRANT ALL PRIVILEGES ON DATABASE strapi TO strapiu;

Now, we close the postgresql bash and the user's session by typing twice exit

postgres=# exit
postgres@user:~$ exit

Now start the servers with

cd app/ && yarn dev
cd api/ && yarn strapi dev

Go to localhost:1337 and create a new admin and user on Strapi

Index page

Then go to the users section and click on "+Add New User".

Now we put some test data, in this case. I created a Test User with email "test@gmail.com" and a password, then we click on the "Save" button

Then go to localhost:3000 and test the app with the created user :) 🚀.

Happy coding 🎉!

Screenshots

Index page

Index page user login

Login

License

Apache License, Version 2.0