Skip to content

supabase-community/supabase-csharp

Repository files navigation

Supabase.Csharp

Build and Test NuGet

Documentation can be found below, on the Supabase Developer Documentation and additionally in the Generated API Docs.

**CHANGELOG is available in the repository root. **

[NOTICE FOR v1.0.0]

  • The supabase-csharp Nuget package has been renamed to Supabase and a depreciation notice set to encourage adoption.
  • Almost all APIs stay the same when migrating from v0.16.x except the change in namespace from Postgrest to Supabase.Postgrest. Some minor refactoring will be required in the codebase.
  • The assembly name has been changed from supabase to Supabase.

Features

  • Integration with Supabase.Realtime
    • Realtime listeners for database changes
  • Integration with Postgrest
    • Access your database using a REST API generated from your schema & database functions
  • Integration with Gotrue
    • User authentication, including OAuth, email/password, and native sign-in
  • Integration with Supabase Storage
    • Store files in S3 with additional managed metadata
  • Integration with Supabase Edge Functions
    • Run serverless functions on the edge
  • Nuget Release

Quickstart

  1. To get started, create a new project in the Supabase Admin Panel.
  2. Grab your Supabase URL and Supabase Public Key from the Admin Panel (Settings -> API Keys).
  3. Initialize the client!

Reminder: supabase-csharp has some APIs that require the service_key rather than the public_key (for instance: the administration of users, bypassing database roles, etc.). If you are using the service_key be sure it is not exposed client side. Additionally, if you need to use both a service account and a public/user account, please do so using a separate client instance for each.

Observability (OpenTelemetry)

The clients emit traces and metrics through System.Diagnostics, so you can wire them into OpenTelemetry (or any ActivityListener/MeterListener) without the clients taking a dependency on the OpenTelemetry packages. Emission is zero-cost while nothing is listening, so it is always on and stays silent until you subscribe.

Rather than registering each client's source by hand, use SupabaseDiagnostics.SourceNames, which gathers the names of every instrumented client. Each client shares one name between its ActivitySource and its Meter, so the same list works for tracing and metrics:

using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
using Supabase;

// Requires the OpenTelemetry.Extensions.Hosting and an exporter package (e.g. OTLP) in your app.
builder.Services.AddOpenTelemetry()
    .WithTracing(tracing => tracing
        .AddSource(SupabaseDiagnostics.SourceNames.ToArray())
        .AddOtlpExporter())
    .WithMetrics(metrics => metrics
        .AddMeter(SupabaseDiagnostics.SourceNames.ToArray())
        .AddOtlpExporter());

This covers the Auth (Gotrue), Postgrest, Functions, and Storage clients. Realtime is not yet instrumented, so no websocket telemetry is emitted. URLs are recorded without their query string, and no token, credential, or payload is placed in a tag. See each client's own README for the specific spans and metrics it produces.

Documentation

Specific Features

Troubleshooting

Package made possible through the efforts of

Join the ranks! See a problem? Help fix it!

Contributing

We are more than happy to have contributions! Please submit a PR.

About

A C# Client library for Supabase

Topics

Resources

License

Code of conduct

Contributing

Stars

693 stars

Watchers

17 watching

Forks

Packages

 
 
 

Contributors