Discord

Integrate Discord Single Sign-On (SSO) in your application.

Create a new application

Click on the New Application button to create a new application.

Redirect URL

Go to OAuth2 page and inside the Redirects section, add the redirect URL.

redirect_uri

Your redirect URL should be https://your-domain.com/login/sso/discord.

Get the Client ID and Client Secret

After creating the application, you will get the Client ID and Client Secret. Save them for later.

Environment Variables (.env)

Add the Client ID and Client Secret to your .env file.

DISCORD_CLIENT_ID=XXX
DISCORD_CLIENT_SECRET=XXX

Configuration in VitNode

Add the Discord SSO plugin to your API routes.

src/app/api/[...route]/route.ts
import { DiscordSSOApiPlugin } from 'vitnode/api/plugins/sso/discord';
 
VitNodeAPI({
  app,
  plugins: [],
  authorization: {
    ssoPlugins: [
      new DiscordSSOApiPlugin({
        clientId: process.env.DISCORD_CLIENT_ID,
        clientSecret: process.env.DISCORD_CLIENT_SECRET,
      }),
    ],
  },
});

Test the SSO

Go to the login page and click on the Discord button to test the SSO.

On this page