This project demonstrates a basic login authentication example using Next.js and the Next-Auth library. The project provides a simple login system where users can log in with a hardcoded username/password or through their GitHub accounts.
- Clone the project to your computer or download and extract the ZIP file.
- Open the terminal and navigate to the project folder:
cd next-auth-app
- Install the necessary dependencies by running the following command:
npm install
- For Github OAuth settings :
- Go to the GitHub Developer Settings page.
- Create a new OAuth application: . Provide an appropriate "Application name" (e.g., Next-Auth Login Tutorial). . In the "Homepage URL" field, enter http://localhost:3000. . In the "Authorization callback URL" field, enter 'http://localhost:3000/api/auth/callback/github'.
- Copy the "Client ID" and "Client Secret" values of the created application.
- Create a file named .env.local in the project root directory and add the following content:
GITHUB_CLIENT_ID=<GitHub Client ID>
GITHUB_CLIENT_SECRET=<GitHub Client Secret>
Replace and with the corresponding values from your GitHub OAuth application.
- Start the project by running the following command:
npm run dev
The project should now be running at http://localhost:3000. Open your browser and navigate to this address to see the project.