This repository demonstrates how to implement OAuth authentication using Auth.js and Discord, along with the ShadCN component library in a Next.js application.
- Authentication: Implemented using Auth.js, replacing NextAuth for a more robust and flexible solution.
- Themes: Support for multiple themes to enhance user customization.
- App Router: Improved navigation using the app router.
- ShadCN UI Library: Modern and cohesive design system for the user interface.
Follow these instructions to set up the project locally.
- Node.js installed on your machine
- Discord Developer account
-
Clone the repository:
git clone https://github.com/Trixzyy/discord-authjs-example.git cd discord-authjs-example
-
Install the dependencies:
npm install
-
Configure Redirect URI in Discord Developer Console:
- Go to the Discord Developer Portal.
- Select your application.
- Navigate to the "OAuth2" section.
- Add
http://localhost:3000/api/auth/callback/discord
to the Redirects field. - Save the changes.
-
Environment Variables: Create a
.env.local
file in the root directory and add your Discord credentials:AUTH_SECRET={AUTH_SECRET} AUTH_DISCORD_ID={YOUR_APPLICATION_ID} AUTH_DISCORD_SECRET={YOUR_SECRET_ID}
To create an auth secret use the command npx auth secret
To start the development server, run:
npm run dev
Open your browser and navigate to http://localhost:3000
.
This project is licensed under the MIT License. See the LICENSE file for details.