Skip to content

devabhixda/supabase-cpp

Repository files navigation

Supabase C++ Library

A C++ library for integrating Supabase into mobile applications (Android and iOS).

Features

  • Complete Supabase REST API integration
  • Support for Android (.so libraries) and iOS (.xcframework)
  • Optional OpenSSL support for HTTPS
  • C and C++ interfaces
  • Query builder with fluent API
  • Support for authentication, database operations, storage, and RPC

Building

Prerequisites

For Android:

  • Android NDK (set ANDROID_NDK environment variable or install via Android Studio)

For iOS:

  • macOS with Xcode installed

Note: OpenSSL is built automatically by the build script for HTTPS support.

Build Command

The project uses a unified build script that builds for both platforms with OpenSSL by default:

# Build for both Android and iOS with OpenSSL (default)
./build.sh

The script will:

  1. Build OpenSSL for Android and iOS
  2. Build Android .so libraries (arm64-v8a, x86_64)
  3. Build iOS .xcframework (device + simulator)
  4. Automatically skip iOS build if not running on macOS

Build Output

  • Android: .so libraries will be generated in lib/ directory

    • lib/libsupabase_arm64-v8a.so
    • lib/libsupabase_x86_64.so
  • iOS: .xcframework will be generated in ios/ directory

    • ios/supabase.xcframework/

Usage

C++ Interface

#include "supabase.h"

// Initialize client
Supabase::Client client;
client.begin("https://your-project.supabase.co", "your-anon-key");

// Insert data
std::string json = R"({"name": "John", "age": 30})";
int status = client.insert("users", json);

// Query data
std::string result = client.from("users")
    .select("*")
    .eq("age", "30")
    .execute();

// RPC call
std::string rpc_result = client.rpc("my_function", R"({"param": "value"})");

C Interface

#include "supabase.h"

// Initialize
supabase_client_t client;
supabase_init(&client, "https://your-project.supabase.co", "your-anon-key");

// Insert
supabase_insert(&client, "users", "{\"name\": \"John\"}", 0);

// Select
char* result = supabase_select(&client, "users", "*", "age=30");
if (result) {
    printf("Result: %s\n", result);
    supabase_free_string(result);
}

// Cleanup
supabase_cleanup(&client);

Project Structure

.
├── build.sh                    # Unified build script for Android and iOS
├── build_openssl_android.sh    # OpenSSL build script for Android
├── build_openssl_ios.sh        # OpenSSL build script for iOS
├── CMakeLists.txt              # CMake configuration
├── Makefile                    # Alternative build system
├── src/
│   └── supabase.cpp            # Supabase implementation
├── include/
│   └── supabase.h              # Public API header
└── third_party/
    ├── httplib/                # HTTP client library
    └── nlohmann/               # JSON library

License

See LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published