Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(studio): add dotnet framework to Connect flow (#51257)

Guillaume Faas7625a0353e35
diff --git a/apps/studio/components/interfaces/ConnectSheet/Connect.constants.ts b/apps/studio/components/interfaces/ConnectSheet/Connect.constants.ts
index 0339d07cd8c..e4c33fd1d91 100644
--- a/apps/studio/components/interfaces/ConnectSheet/Connect.constants.ts
+++ b/apps/studio/components/interfaces/ConnectSheet/Connect.constants.ts
@@ -268,6 +268,53 @@ export const FRAMEWORKS: ConnectionType[] = [
},
],
},
+ {
+ key: 'dotnet',
+ label: '.NET',
+ icon: 'dotnet',
+ guideLink: `${DOCS_URL}/reference/csharp/introduction`,
+ children: [
+ {
+ key: 'aspnetcore',
+ label: 'ASP.NET Core & Blazor',
+ icon: '',
+ children: [
+ {
+ key: 'supabasedotnet',
+ label: 'supabase-dotnet',
+ icon: 'supabase',
+ children: [],
+ },
+ ],
+ },
+ {
+ key: 'console',
+ label: 'Console / desktop',
+ icon: '',
+ children: [
+ {
+ key: 'supabasedotnet',
+ label: 'supabase-dotnet',
+ icon: 'supabase',
+ children: [],
+ },
+ ],
+ },
+ {
+ key: 'unity',
+ label: 'Unity',
+ icon: '',
+ children: [
+ {
+ key: 'supabasedotnet',
+ label: 'supabase-dotnet',
+ icon: 'supabase',
+ children: [],
+ },
+ ],
+ },
+ ],
+ },
]
export const MOBILES: ConnectionType[] = [
diff --git a/apps/studio/components/interfaces/ConnectSheet/__tests__/connect.schema.test.ts b/apps/studio/components/interfaces/ConnectSheet/__tests__/connect.schema.test.ts
index 3582a1a4d44..07d9727967e 100644
--- a/apps/studio/components/interfaces/ConnectSheet/__tests__/connect.schema.test.ts
+++ b/apps/studio/components/interfaces/ConnectSheet/__tests__/connect.schema.test.ts
@@ -80,7 +80,7 @@ describe('connect.schema:fields', () => {
test('frameworkVariant field should depend on framework', () => {
const field = connectSchema.fields.frameworkVariant
- expect(field.dependsOn).toEqual({ framework: ['nextjs', 'react'] })
+ expect(field.dependsOn).toEqual({ framework: ['nextjs', 'react', 'dotnet'] })
})
test('frameworkUi field should be a switch type', () => {
diff --git a/apps/studio/components/interfaces/ConnectSheet/connect.schema.ts b/apps/studio/components/interfaces/ConnectSheet/connect.schema.ts
index ffb2b5f014c..8e8c4867cfc 100644
--- a/apps/studio/components/interfaces/ConnectSheet/connect.schema.ts
+++ b/apps/studio/components/interfaces/ConnectSheet/connect.schema.ts
@@ -36,6 +36,7 @@ export const INSTALL_COMMANDS: Record<string, string> = {
supabaseflutter: 'flutter pub add supabase_flutter',
supabaseswift: 'swift package add-dependency https://github.com/supabase/supabase-swift',
supabasekt: 'implementation("io.github.jan-tennert.supabase:supabase-kt:VERSION")',
+ supabasedotnet: 'dotnet add package Supabase',
}
/**
@@ -77,6 +78,22 @@ const frameworkConfigureStep: StepDefinition = {
content: '{{framework}}/{{frameworkVariant}}/{{library}}',
}
+const dotnetUnityInstallStep: StepDefinition = {
+ id: 'install',
+ title: 'Install package',
+ description: 'Add the Supabase SDK to your Unity project.',
+ content: 'dotnet/unity/install',
+}
+
+// ASP.NET Core also needs the dependency injection extension package, so it
+// gets its own install step instead of the shared single-package one.
+const dotnetAspnetInstallStep: StepDefinition = {
+ id: 'install',
+ title: 'Install packages',
+ description: 'Run these commands to install the required dependencies.',
+ content: 'dotnet/aspnetcore/install',
+}
+
const frameworkNextJsFilesStep: StepDefinition = {
id: 'configure-nextjs',
title: 'Add files',
@@ -319,7 +336,7 @@ export const connectSchema: ConnectSchema = {
label: 'Variant',
options: { source: 'frameworkVariants' },
defaultValue: 'app',
- dependsOn: { framework: ['nextjs', 'react'] }, // Only show for frameworks with multiple variants
+ dependsOn: { framework: ['nextjs', 'react', 'dotnet'] }, // Only show for frameworks with multiple variants
},
library: {
id: 'library',
@@ -460,6 +477,13 @@ export const connectSchema: ConnectSchema = {
},
},
remix: [frameworkInstallPackagesStep, frameworkConfigureStep, skillsInstallStep],
+ dotnet: {
+ frameworkVariant: {
+ aspnetcore: [dotnetAspnetInstallStep, frameworkConfigureStep, skillsInstallStep],
+ unity: [dotnetUnityInstallStep, frameworkConfigureStep, skillsInstallStep],
+ DEFAULT: [frameworkInstallStep, frameworkConfigureStep, skillsInstallStep],
+ },
+ },
DEFAULT: [frameworkInstallStep, frameworkConfigureStep, skillsInstallStep],
},
},
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/dotnet/aspnetcore/install/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/dotnet/aspnetcore/install/content.tsx
new file mode 100644
index 00000000000..274987c9b9d
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/dotnet/aspnetcore/install/content.tsx
@@ -0,0 +1,19 @@
+import { CodeBlock } from 'ui-patterns/CodeBlock'
+
+import { INSTALL_COMMANDS } from '@/components/interfaces/ConnectSheet/connect.schema'
+
+const command = [
+ INSTALL_COMMANDS.supabasedotnet,
+ 'dotnet add package Supabase.Extensions.DependencyInjection',
+].join('\n')
+
+const InstallContent = () => {
+ return (
+ <CodeBlock className="[&_code]:text-foreground" value={command} hideLineNumbers language="bash">
+ {command}
+ </CodeBlock>
+ )
+}
+
+// Used as a dynamic import
+export default InstallContent
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/dotnet/aspnetcore/supabasedotnet/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/dotnet/aspnetcore/supabasedotnet/content.tsx
new file mode 100644
index 00000000000..d29cbe771b9
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/dotnet/aspnetcore/supabasedotnet/content.tsx
@@ -0,0 +1,80 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const supabaseUrl = projectKeys.apiUrl ?? 'your-project-url'
+ const supabaseKey = projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'
+
+ const files = [
+ {
+ name: 'appsettings.json',
+ language: 'json',
+ code: `
+{
+ "Supabase": {
+ "Url": "${supabaseUrl}",
+ "Key": "${supabaseKey}"
+ }
+}
+`,
+ },
+ {
+ name: 'Program.cs',
+ language: 'csharp',
+ code: `
+using Supabase.Extensions.DependencyInjection;
+
+var builder = WebApplication.CreateBuilder(args);
+
+// Registers Supabase.Client and each of its sub-clients (Auth, Postgrest,
+// Storage, Functions, Realtime) in the DI container, backed by pooled
+// HttpClients from IHttpClientFactory.
+//
+// Blazor registers the client the same way: use this in your Blazor Server /
+// Web App Program.cs, or WebAssemblyHostBuilder.CreateDefault(args) for a
+// Blazor WebAssembly client.
+builder.Services.AddSupabase(
+ builder.Configuration["Supabase:Url"]!,
+ builder.Configuration["Supabase:Key"]!
+);
+
+var app = builder.Build();
+
+// Inject Supabase.Client (or a single sub-client) wherever you need it — a
+// minimal API endpoint here, or a @inject in a Blazor component.
+app.MapGet("/todos", async (Supabase.Client supabase) =>
+{
+ await supabase.InitializeAsync();
+ var response = await supabase.From<Todo>().Get();
+ return response.Models;
+});
+
+app.Run();
+`,
+ },
+ {
+ name: 'Models/Todo.cs',
+ language: 'csharp',
+ code: `
+using Supabase.Postgrest.Attributes;
+using Supabase.Postgrest.Models;
+
+[Table("todos")]
+public class Todo : BaseModel
+{
+ [PrimaryKey("id")]
+ public long Id { get; set; }
+
+ [Column("name")]
+ public string Name { get; set; } = string.Empty;
+}
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+// Used as a dynamic import
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/dotnet/console/supabasedotnet/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/dotnet/console/supabasedotnet/content.tsx
new file mode 100644
index 00000000000..d5fe68ac9d0
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/dotnet/console/supabasedotnet/content.tsx
@@ -0,0 +1,56 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const supabaseUrl = projectKeys.apiUrl ?? 'your-project-url'
+ const supabaseKey = projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'
+
+ const files = [
+ {
+ name: 'Program.cs',
+ language: 'csharp',
+ code: `
+using Supabase;
+
+var url = "${supabaseUrl}";
+var key = "${supabaseKey}";
+
+var supabase = new Client(url, key, new SupabaseOptions
+{
+ AutoConnectRealtime = true
+});
+await supabase.InitializeAsync();
+
+var response = await supabase.From<Todo>().Get();
+foreach (var todo in response.Models)
+{
+ Console.WriteLine(todo.Name);
+}
+`,
+ },
+ {
+ name: 'Todo.cs',
+ language: 'csharp',
+ code: `
+using Supabase.Postgrest.Attributes;
+using Supabase.Postgrest.Models;
+
+[Table("todos")]
+public class Todo : BaseModel
+{
+ [PrimaryKey("id")]
+ public long Id { get; set; }
+
+ [Column("name")]
+ public string Name { get; set; } = string.Empty;
+}
+`,
+ },
+ ]
+
+ return <MultipleCodeBlock files={files} />
+}
+
+// Used as a dynamic import
+export default ContentFile
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/dotnet/unity/install/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/dotnet/unity/install/content.tsx
new file mode 100644
index 00000000000..cc209cdb292
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/dotnet/unity/install/content.tsx
@@ -0,0 +1,34 @@
+import { CodeBlock } from 'ui-patterns/CodeBlock'
+
+const nugetForUnityGitUrl =
+ 'https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity'
+
+const InstallContent = () => {
+ return (
+ <div className="flex flex-col gap-y-4">
+ <div className="flex flex-col gap-y-2">
+ <p className="text-sm text-foreground-light">
+ Unity resolves NuGet packages through NuGetForUnity. Install it from the Package Manager
+ via <span className="text-foreground">Add package from git URL</span>:
+ </p>
+ <CodeBlock
+ className="[&_code]:text-foreground"
+ value={nugetForUnityGitUrl}
+ hideLineNumbers
+ language="bash"
+ >
+ {nugetForUnityGitUrl}
+ </CodeBlock>
+ </div>
+ <p className="text-sm text-foreground-light">
+ Then open <span className="text-foreground">Window → NuGet → Manage NuGet Packages</span>,
+ search for <span className="text-foreground">Supabase</span>, and install it. If you build
+ with IL2CPP, preserve your model types from managed code stripping with a{' '}
+ <span className="text-foreground">link.xml</span>.
+ </p>
+ </div>
+ )
+}
+
+// Used as a dynamic import
+export default InstallContent
diff --git a/apps/studio/components/interfaces/ConnectSheet/content/dotnet/unity/supabasedotnet/content.tsx b/apps/studio/components/interfaces/ConnectSheet/content/dotnet/unity/supabasedotnet/content.tsx
new file mode 100644
index 00000000000..d15423e817b
--- /dev/null
+++ b/apps/studio/components/interfaces/ConnectSheet/content/dotnet/unity/supabasedotnet/content.tsx
@@ -0,0 +1,117 @@
+import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
+
+import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
+
+const ContentFile = ({ projectKeys }: StepContentProps) => {
+ const supabaseUrl = projectKeys.apiUrl ?? 'your-project-url'
+ const supabaseKey = projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'
+
+ const files = [
+ {
+ name: 'SupabaseManager.cs',
+ language: 'csharp',
+ code: `
+using System.Threading.Tasks;
+using Supabase;
+using UnityEngine;
+
+// Keep a single client alive for the whole game and expose it through a
+// MonoBehaviour singleton that survives scene loads.
+public class SupabaseManager : MonoBehaviour
+{
+ public static SupabaseManager Instance { get; private set; }
+ public Client Supabase { get; private set; }
+
+ // Await this before using the client. Awake returns at the first await, so
+ // other scripts could run before InitializeAsync() finishes without it.
+ public Task InitializationTask { get; private set; }
+
+ private const string Url = "${supabaseUrl}";
+ private const string Key = "${supabaseKey}";
+
+ private void Awake()
+ {
+ if (Instance != null)
+ {
+ Destroy(gameObject);
+ return;
+ }
+
+ Instance = this;
+ DontDestroyOnLoad(gameObject);
+ InitializationTask = InitializeAsync();
+ }
+
+ private async Task InitializeAsync()
+ {
+ Supabase = new Client(Url, Key, new SupabaseOptions
+ {
+ AutoConnectRealtime = true
+ });
+ await Supabase.InitializeAsync();
+ }
+}
+`,
+ },
+ {
+ name: 'TodoList.cs',
+ language: 'csharp',
+ code: `
+using System.Threading.Tasks;
+using UnityEngine;
+
+public class TodoList : MonoBehaviour
+{
+ // Start() can't be awaited, so kick off the async work from a Task method.
+ private void Start()
+ {
+ _ = LoadTodosAsync();
+ }
+
+ private async Task LoadTodosAsync()
+ {
+ var manager = SupabaseManager.Instance;
+ await manager.InitializationTask;
+
+ var response = await manager.Supabase.From<Todo>().Get();
+ foreach (var todo in response.Models)
+ {
+ Debug.Log(todo.Name);
+ }
+ }
+}
+`,
+ },
+ {
+ name: 'Todo.cs',
+ language: 'csharp',
+ code: `
+using Supabase.Postgrest.Attributes;
+using Supabase.Postgrest.Models;
+
+[Table("todos")]
+public class Todo : BaseModel
+{
+ [PrimaryKey("id")]
+ public long Id { get; set; }
+
+ [Column("name")]
+ public string Name { get; set; } = string.Empty;
+}
+`,
+ },
+ ]
+
+ return (
+ <div className="flex flex-col gap-y-4">
+ <p className="text-sm text-foreground-light">
+ Before running the sample, attach <code>SupabaseManager</code> to an active GameObject and
+ attach <code>TodoList</code> to an active GameObject in the scene.
+ </p>
+ <MultipleCodeBlock files={files} />
+ </div>
+ )
+}
+
+// Used as a dynamic import
+export default ContentFile
diff --git a/apps/studio/public/img/libraries/dotnet-icon.svg b/apps/studio/public/img/libraries/dotnet-icon.svg
new file mode 100644
index 00000000000..d204a090424
--- /dev/null
+++ b/apps/studio/public/img/libraries/dotnet-icon.svg
@@ -0,0 +1,7 @@
+<svg width="456" height="456" viewBox="0 0 456 456" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="456" height="456" fill="#512BD4"/>
+<path d="M81.2738 291.333C78.0496 291.333 75.309 290.259 73.052 288.11C70.795 285.906 69.6665 283.289 69.6665 280.259C69.6665 277.173 70.795 274.529 73.052 272.325C75.309 270.121 78.0496 269.019 81.2738 269.019C84.5518 269.019 87.3193 270.121 89.5763 272.325C91.887 274.529 93.0424 277.173 93.0424 280.259C93.0424 283.289 91.887 285.906 89.5763 288.11C87.3193 290.259 84.5518 291.333 81.2738 291.333Z" fill="white"/>
+<path d="M210.167 289.515H189.209L133.994 202.406C132.597 200.202 131.441 197.915 130.528 195.546H130.044C130.474 198.081 130.689 203.508 130.689 211.827V289.515H112.149V171H134.477L187.839 256.043C190.096 259.57 191.547 261.994 192.192 263.316H192.514C191.977 260.176 191.708 254.859 191.708 247.365V171H210.167V289.515Z" fill="white"/>
+<path d="M300.449 289.515H235.561V171H297.87V187.695H254.746V221.249H294.485V237.861H254.746V272.903H300.449V289.515Z" fill="white"/>
+<path d="M392.667 187.695H359.457V289.515H340.272V187.695H307.143V171H392.667V187.695Z" fill="white"/>
+</svg>