Discord Activities

Integrate your Rivet game with Discord Activities.

Set up Discord SDK

Set up the Discord SDK (docs):

// Import the SDK
import { DiscordSDK } from "@discord/embedded-app-sdk";

// Instantiate the SDK 
const discordSdk = new DiscordSDK(process.env.DISCORD_CLIENT_ID);

setupDiscordSdk().then(() => {
    console.log("Discord SDK is ready");
});

async function setupDiscordSdk() {
    await discordSdk.ready();
}
JavaScript

Update lobbies code

Update your Rivet matchmaking code to include tags:

const res = await rivet.lobbies.findOrCreate({
    tags: {
        // Discord SDK set up in previous step
        instanceId: discordSdk.instanceId,
    },
    // ...
});
JavaScript

Set up route mapping

After following the activity tutorial, access the URL mapping for your Discord app and configure it like so:

PrefixTarget
/gstaticfonts.gstatic.com/
/wslobby.rivet.run/
/apiapi.rivet.gg/
/asteroids-xxx.rivet.game/

Run activity

Run activity (read docs here)


Example repo

A fully integrated example can be found here. (This is using a slightly dated API, but is lagely identical.)