5-Minute Discord Integration Guide
Integrating With Discord Connect in 5 Minutes
Discord Connect is a simple way to let users log in to your app using their Discord account.
This module does the heavy lifting of integrating your Co:Create app with Discord Connect.
It takes in your Co:Create app's settings and returns a link that you can use to connect a user's Discord account to your app.
The link will redirect the user to Discord, where they can log in to their Discord account and authorize your app to access their account.
Prerequisites
-
Node.js 16 LTS
or higher -
NPM
orYarn
-
Your app to serve on
localhost:3000
Installation
npm install @usecocreate/sdk
Usage
Import the discord
module from the SDK.
import { discord } from "@usecocreate/sdk";
The example below shows the connectDiscordLink
function that returns a Discord connect link based on your Co:Create app's settings:
import React from "react";
import { discord } from "@usecocreate/sdk";
function DiscordConnectButton() {
const link = discord.connectDiscordLink({
clientId: "560d0d00-0f02-47e3-a1ae-c349bb46874e",
redirectUrl: "http://localhost:3000/discord_test",
userEmail: "[email protected]",
sessionVerifier: "my_session_verifier",
});
return (
<a href={link} target="_blank" rel="noopener noreferrer">
Connect Discord
</a>
);
}
export default DiscordConnectButton;
Parameters
Name | Type | Description | optional |
---|---|---|---|
clientId | string | The client id from your Co:Create Admin Portal. | no |
redirectUrl | string | The URL to redirect to after the user has connected their Discord account. Must be in the URL allowlist for the app id. | no |
userEmail | string | The user's email. | no |
sessionVerifier | string | A unique token that is sent back in the redirect URL. This can be used to verify that the callback is coming from Co:Create. | no |
Get Help
If you get stuck at any time, reach out to us on Discord or contact us via email at [email protected].
Updated over 1 year ago