DiscordEmbeddedSdk 1.0.1

dotnet add package DiscordEmbeddedSdk --version 1.0.1
                    
NuGet\Install-Package DiscordEmbeddedSdk -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DiscordEmbeddedSdk" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DiscordEmbeddedSdk" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="DiscordEmbeddedSdk" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DiscordEmbeddedSdk --version 1.0.1
                    
#r "nuget: DiscordEmbeddedSdk, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DiscordEmbeddedSdk@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DiscordEmbeddedSdk&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=DiscordEmbeddedSdk&version=1.0.1
                    
Install as a Cake Tool

<div align="center"> <img alt="DiscordEmbeddedSdk Logo" src="https://raw.githubusercontent.com/ChiaraBm/DiscordEmbeddedSdk/refs/heads/main/Assets/logo.svg" width="120" /> <h1>DiscordEmbeddedSdk</h1> <p><strong>A blazor wrapper for the <a href="https://github.com/discord/embedded-app-sdk">Discord Embedded App SDK</a></strong></p> </div>

A Blazor wrapper around the Discord Embedded App SDK. It handles JavaScript interop so you can build Discord Activities in C# without touching the JS layer directly.

Installation

Register the service in your DI container:

builder.Services.AddDiscordEmbedSdk();

Getting Started

The setup flow follows three steps: initialize the module, subscribe to READY and ERROR, then call ReadyAsync to connect.

var clientId = Configuration.GetValue<string>("Discord:ClientId");

await SdkService.SetupAsync(clientId);

SdkService.OnReady += async ready =>
{
    Console.WriteLine($"Connected to {ready.Config.ApiEndpoint}");
    // continue setup here
};

SdkService.OnError += async error =>
{
    Console.WriteLine($"Error {error.Code}: {error.Message}");
};

await SdkService.SubscribeAsync(DiscordEventType.Ready);
await SdkService.SubscribeAsync(DiscordEventType.Error);

await SdkService.ReadyAsync();

Authorization and Authentication

Inside your OnReady handler, authorize the user to get a code, exchange it for an access token on your backend, then authenticate with the SDK.

SdkService.OnReady += async _ =>
{
    var authorizeResult = await SdkService.AuthorizeAsync(clientId, [
        "identify",
        "guilds",
        "rpc.activities.write"
    ], prompt: "none");

    // Exchange the code for an access token on your own backend
    var response = await HttpClient.PostAsync("token", new StringContent(authorizeResult.Code));
    var accessToken = await response.Content.ReadAsStringAsync();

    var authResult = await SdkService.AuthenticateAsync(accessToken);
    Console.WriteLine($"Welcome, {authResult.User.Username}");
};

Getting Channel Info

var channelId = await SdkService.GetCurrentChannelAsync();
var channel = await SdkService.GetChannelAsync(channelId);

Console.WriteLine($"Channel: {channel.Name}");

foreach (var state in channel.VoiceStates)
{
    Console.WriteLine($"{state.User.Username} - Volume: {state.Volume}");
}

Setting Rich Presence

await SdkService.SetActivityAsync(new Activity
{
    Type = 0,
    Details = "In the lobby",
    State = "Waiting for players",
    Assets = new ActivityAssets
    {
        LargeImage = "my_image_key",
        LargeText = "My Game",
        SmallImage = "icon_key",
        SmallText = "v1.0"
    }
});

Subscribing to Events

Subscribe to voice and speaking events by passing a channel ID.

await SdkService.SubscribeSpeakingStartAsync(channelId: channelId);
await SdkService.SubscribeSpeakingStopAsync(channelId: channelId);
await SdkService.SubscribeVoiceStateUpdateAsync(channelId);

SdkService.OnSpeakingStart += async result =>
{
    Console.WriteLine($"User {result.UserId} started speaking");
};

SdkService.OnSpeakingStop += async result =>
{
    Console.WriteLine($"User {result.UserId} stopped speaking");
};

SdkService.OnVoiceStateUpdate += async result =>
{
    Console.WriteLine($"Muted: {result.SelfMute}, Deafened: {result.SelfDeaf}");
};

Other events require no payload:

await SdkService.SubscribeCurrentUserUpdateAsync();
await SdkService.SubscribeActivityInstanceParticipantsUpdateAsync();

SdkService.OnCurrentUserUpdate += async user =>
{
    Console.WriteLine($"User updated: {user.Username}");
};

SdkService.OnActivityInstanceParticipantsUpdate += async update =>
{
    Console.WriteLine($"Participants: {update.Participants.Count}");
};

Sharing

// Share a link
var result = await SdkService.ShareLinkAsync("Come join my game!", customId: "my_invite");
if (result.Success)
    Console.WriteLine("Link shared!");

// Open an external URL
await SdkService.OpenExternalLinkAsync("https://example.com");

Closing the App

await SdkService.CloseAsync(RpcCloseCode.CloseNormal, "Thanks for playing!");

Example Project

A full working example is available in the tests folder. It covers the complete auth flow, retrieving channel and participant data, setting activity, and subscribing to voice events.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 82 2/26/2026
1.0.0 85 2/26/2026