This guide will help you integrate a dynamic Discord status widget into your Next.js project.
- Create a folder named
components
in your project folder if it doesn't exist. - Inside the
components
folder, create a file namedDiscordStatus.js
. - Copy the code for the Discord Status component from this link and paste it into
DiscordStatus.js
.
- Create a folder named
public
in your project root if it doesn't exist. - Inside the
public
folder, create a subfolder namedstatus
. - Download the status images from this folder and place them in the
public/status
folder.
To display your own Discord status, you need to use your Discord user ID:
-
Enable Developer Mode in Discord:
-
Right-click on your profile in a Discord chat and copy your user ID:
To get your Discord status information, we are using the Lanyard API. For the widget to show your own status Join this Discord server and your discord data will be visible at https://api.lanyard.rest/v1/users/[your_id_here]
Learn more about the Lanyard API.
Open the DiscordStatus.js
file and replace the user ID in the fetch URL with your own:
-
In the file where you want to display the widget (e.g.,
app/page.js
), import theDiscordStatus
component:import DiscordStatus from '@/components/DiscordStatus';
-
Add the
DiscordStatus
component in your JSX:<DiscordStatus />
Here's an example of how to integrate it:
After following these steps, your Discord status widget should be integrated and look similar to this:
It will change according to your current Discord status.