Git Product home page Git Product logo

discord-next-auth-example's Introduction


Discord Auth.js Example

This repository demonstrates how to implement OAuth authentication using Auth.js and Discord, along with the ShadCN component library in a Next.js application.

Auth GIF Demo

Table of Contents

Features

  • 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.

Getting Started

Follow these instructions to set up the project locally.

Prerequisites

  • Node.js installed on your machine
  • Discord Developer account

Installation

  1. Clone the repository:

    git clone https://github.com/Trixzyy/discord-authjs-example.git
    cd discord-authjs-example
  2. Install the dependencies:

    npm install

Configuration

  1. 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.
  2. 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

Running the Application

To start the development server, run:

npm run dev

Open your browser and navigate to http://localhost:3000.

License

This project is licensed under the MIT License. See the LICENSE file for details.


discord-next-auth-example's People

Contributors

trixzyy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

discord-next-auth-example's Issues

Upgrade to next 13

NextJS recently updated to the new Version 13.
There was a big change on how the folder structure is built, would be nice to have a nextjs 13 version of this repository :)

Discord Redirect URI Configuration Instruction is Missing

Description:
There is a crucial step missing in the documentation for setting up Discord OAuth with next-auth. Without configuring the Redirect URI in the Discord Developer Console, the authentication process will fail.

Steps to Reproduce:

Follow the current documentation to set up Discord OAuth with next-auth.
Attempt to authenticate with Discord.
Observe the failure.
Expected Behavior:
The documentation should include a step to configure the Redirect URI in the Discord Developer Console.

Proposed Solution:
Add the following step to the documentation:

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.
Without this configuration, the authentication will not work, leading to potential confusion for developers following the setup guide.

Screenshot 2024-05-19 at 13 01 28

Additional Context:
This step is essential for the OAuth flow to complete successfully. Including it in the documentation will help prevent authentication errors and improve the overall developer experience.

Redirects to localhost

Everytime I click on authorize, it just sends me to https://localhost:3000/api/auth/error?error=Configuration

even though I'm not on localhost.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.