RDS Supabase SDK

更新时间:
复制 MD 格式

This guide shows you how to use the RDS Supabase SDK in various programming languages.

Prerequisites

Create an RDS Supabase project.

Supabase URL and Supabase Key

  1. Go to the RDS console homepage. In the left-side navigation pane, click AI Application Development .

  2. Select a region at the top. In the RDS Supabase list, find your target project and click View Details in the Actions column.

  3. On the Basic Information page, in the White list information section, click Create Whitelist to add your client's IP address.

  4. In the Network Information section, click the Outside the network connection address to open the RDS Supabase login page.

  5. Enter the default username Supabase and the password to log in to your RDS Supabase project.

  6. Click Connect. In the Connect to your project dialog box, click App Frameworks to get your Supabase URL and Supabase Key.

    Set Framework to Next.js, Using to App Router, and With to supabase-js. On the .env.local tab, you can find the environment variables NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY.

SDKs by language

JavaScript

  1. Install the @supabase/supabase-js package.

    npm install @supabase/supabase-js
  2. Use the Supabase SDK in your code. The following is an example:

    import { createClient } from "@supabase/supabase-js";
    
    // Store your Supabase URL and Key in environment variables for security,
    // which prevents them from being exposed in client-side code.
    const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
    const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
    
    const supabase = createClient(supabaseUrl, supabaseKey);
    

Python

  1. Install the supabase package.

    pip install supabase
  2. Use the Supabase SDK in your code. The following is an example:

    import os
    from supabase import create_client, Client
    
    # Load environment variables for security.
    url: str = os.environ.get("SUPABASE_URL")
    key: str = os.environ.get("SUPABASE_KEY")
    
    supabase: Client = create_client(url, key)

Flutter

  1. Install the supabase_flutter package.

    flutter pub add supabase_flutter
  2. Use the Supabase SDK in your code. The following is an example:

    Future<void> main() async {
      await Supabase.initialize(
        // Load the URL and key from a secure configuration for security.
        url: 'YOUR_SUPABASE_URL',
        anonKey: 'YOUR_SUPABASE_ANON_KEY',
      );
      runApp(MyApp());
    }
    // Get a reference to your Supabase client
    final supabase = Supabase.instance.client;

Swift

  1. Install the supabase-swift package by adding it as a dependency in your Package.swift file.

    let package = Package(
        ...
        dependencies: [
            ...
            .package(
                url: "https://github.com/supabase/supabase-swift.git",
                from: "2.0.0"
            ),
        ],
        targets: [
            .target(
                name: "YourTargetName",
                dependencies: [
                    .product(
                        name: "Supabase", // Auth, Realtime, Postgrest, Functions, or Storage
                        package: "supabase-swift"
                    ),
                ]
            )
        ]
    )
  2. Use the Supabase SDK in your code. The following is an example:

    import Supabase
    
    // Load the URL and key from a secure configuration for security.
    let client = SupabaseClient(
      supabaseURL: URL(string: "YOUR_SUPABASE_URL")!,
      supabaseKey: "YOUR_SUPABASE_ANON_KEY"
    )

C#

  1. Install the supabase-csharp package.

    dotnet add package supabase-csharp
  2. Use the Supabase SDK in your code. The following is an example:

    var url = Environment.GetEnvironmentVariable("SUPABASE_URL");
    var key = Environment.GetEnvironmentVariable("SUPABASE_KEY");
    
    var options = new Supabase.SupabaseOptions
    {
        AutoConnectRealtime = true
    };
    
    var supabase = new Supabase.Client(url, key, options);
    await supabase.InitializeAsync();

Kotlin

Use the Supabase SDK in your code. The following is an example:

val supabase = createSupabaseClient(
    // Load the URL and key from a secure configuration for security.
    supabaseUrl = "YOUR_SUPABASE_URL",
    supabaseKey = "YOUR_SUPABASE_ANON_KEY"
) {
    install(Auth)
    install(Postgrest)
    //install other modules
}

For more information, see https://supabase.com/docs.