Boost your Golang backend with the API: A seamless guide to setting up and utilizing supabase for efficient database operations and authentication. supabase Summary has emerged as a compelling open-source alternative to Firebase, offering a suite of tools including a database, authentication, real-time subscriptions, and storage. For Golang developers, integrating it can seem daunting due to the lack of proper library support. supabase However, the library provides a simplified way to interact with in your Golang projects. This article will guide you through setting up the library and demonstrate its use in a Golang backend project, ensuring you can leverage ’s powerful features with minimal hassle. supa supabase supa supabase Installation To begin, install in your Golang project. supa go get github.com/lengzuo/supa Setting Up Supabase in Your Golang Project Before diving into the code, ensure you have setup a supabase project. From your supabase project dashboard, note down the and the . These will be required to connect your Golang application to supabase. Project Ref Project API keys Configuration Import the library along with other necessary packages in your Golang project. supa package main import ( "fmt" "github.com/lengzuo/supa" ) func main() { conf := supabase.Config{ // Your project api key, you can use either `anon` or `service_role`. // but i will suggest you to use `service_role` as your api key and keep it secret. ApiKey: "your-project-api-key", // Retrieve your project ref from project url // eg: https://this-your-project-ref.supabase.co ProjectRef: "your-project-ref", // Set it `false` in production to avoid extra log print. Debug: true, } supaClient, err := supabase.New(conf) if err != nil { fmt.Println("failed in init supa client: ", err) return } } Replace and according from your project. your-project-api-key your-project-ref supabase Use Case func signUp(supaClient *supabase.Client) { body := dto.SignUpRequest{ Email: "user@email.com", Password: "user-password", } resp, err := supaClient.Auth.SignUp(ctx, body) if err != nil { var supaErr catch.Exception // use this to catch the error of http status code != 2xx if errors.As(err, &supaErr) { log.Error("status: %d, err: %s", supaErr.StatusCode(), supaErr.Error()) return } fmt.Println("failed in sign up: ", err) return } bytes, _ := json.Marshal(resp) fmt.Printf("sign up success: %s", bytes) } func signInWithPassword(supaClient *supabase.Client) { body := dto.SignInRequest{ Email: "user@email.com", Password: "user-password", } resp, err := supaClient.Auth.SignInWithPassword(ctx, body) if err != nil { ... } bytes, _ := json.Marshal(resp) fmt.Printf("sign in with password success: %s", bytes) } func getAuthUser(supaClient *supabase.Client) { token = "logged-in-access-token" user, err := supaClient.Auth.User(ctx, token) if err != nil { ... } bytes, _ := json.Marshal(resp) fmt.Printf("sign in with password success: %s", bytes) } There are more example functions such as and in the repo for your reference. RPC DB operation Github Conclusion In my personal experience with other Golang libraries, I find the library to be the most developer-friendly. It offers extensive authentication APIs such as SignInWithOTP, SignInWithOAuth, and more. Additionally, it allows developers to pass in for each operation. supabase supa context Besides that, it streamlines the process of integrating a robust backend database and authentication. With just a few lines of code, you can harness the power of supabase in your applications, making your development process more efficient and dynamic.