Skip to content

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

1.2 KB
Raw Blame
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-publishable-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