supabase-community / supabase-go

A Go Client library for Supabase
MIT License
226 stars 19 forks source link

An isomorphic Go client for Supabase.

Features

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-go 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.

Documentation

Get Started

First of all, you need to install the library:

  go get github.com/supabase-community/supabase-go

Then you can use

  client, err := supabase.NewClient(API_URL, API_KEY, &supabase.ClientOptions{})
  if err != nil {
    fmt.Println("cannot initalize client", err)
  }
  data, count, err := client.From("countries").Select("*", "exact", false).Execute()

Use authenticated client


 client, err := supabase.NewClient(API_URL, API_KEY, &supabase.ClientOptions{})
 if err != nil {
  fmt.Println("cannot initalize client", err)
 }
 client.SignInWithEmailPassword(USER_EMAIL, USER_PASSWORD)